mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:22:45 +00:00 
			
		
		
		
	 b10fee00eb
			
		
	
	
		b10fee00eb
		
	
	
	
	
		
			
			This aligns Workers and Window and MessagePorts to all use the same mechanism for transferring serialized messages across realms. It also allows transferring more message ports into a worker. Re-enable the Worker-echo test, as none of the MessagePort tests have themselves been flaky, and those are now using the same underlying implementation.
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			991 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			991 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     asyncTest((done) => {
 | |
|         let work = new Worker("worker.js");
 | |
|         let channel = new MessageChannel();
 | |
| 
 | |
|         function finishTest() {
 | |
|             println("DONE");
 | |
|             work.onmessage = null;
 | |
|             work.terminate();
 | |
|             channel.port2.onmessage = null;
 | |
|             done();
 | |
|         }
 | |
|         let count = 0;
 | |
|         work.onmessage = (evt) => {
 | |
|             println("Got message from worker: " + JSON.stringify(evt.data));
 | |
|             count++;
 | |
|             if (count === 3) {
 | |
|                 finishTest();
 | |
|             }
 | |
|         };
 | |
|         channel.port2.onmessage = (evt) => {
 | |
|             println("Got message from port: " + JSON.stringify(evt.data));
 | |
|             channel.port2.postMessage("Hello from port2");
 | |
|             count++;
 | |
|             if (count === 3) {
 | |
|                 finishTest();
 | |
|             }
 | |
|         };
 | |
|         work.postMessage({ port: channel.port1 }, { transfer : [channel.port1]});
 | |
|     });
 | |
| </script>
 |