serviceworker-failure.js (1225B)
1 // Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/. 2 "use strict"; 3 self.importScripts("/resources/testharness.js"); 4 5 let state = "start in worker"; 6 7 self.onmessage = e => { 8 if (e.data === "start in window") { 9 assert_equals(state, "start in worker"); 10 e.source.postMessage(state); 11 state = "we are expecting a messageerror due to the window sending us an RTCEncodedVideoFrame or RTCEncodedAudioFrame"; 12 } else { 13 e.source.postMessage(`worker onmessage was reached when in state "${state}" and data ${e.data}`); 14 } 15 }; 16 17 self.onmessageerror = e => { 18 if (state === "we are expecting a messageerror due to the window sending us an RTCEncodedVideoFrame or RTCEncodedAudioFrame") { 19 assert_equals(e.constructor.name, "ExtendableMessageEvent", "type"); 20 assert_equals(e.data, null, "data"); 21 assert_equals(e.origin, self.origin, "origin"); 22 assert_not_equals(e.source, null, "source"); 23 assert_equals(e.ports.length, 0, "ports length"); 24 25 state = "onmessageerror was received in worker"; 26 e.source.postMessage(state); 27 } else { 28 e.source.postMessage(`worker onmessageerror was reached when in state "${state}" and data ${e.data}`); 29 } 30 };