mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
0a8ff0ad85
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35951 --HG-- extra : source : 62f3501af4bc1c0bd1ee1977a28aee04706a6663
31 lines
858 B
JavaScript
31 lines
858 B
JavaScript
var clients = new Array();
|
|
clients.length = 0;
|
|
|
|
var broadcast = function(message) {
|
|
var length = clients.length;
|
|
for (var i = 0; i < length; i++) {
|
|
port = clients[i];
|
|
port.postMessage(message);
|
|
}
|
|
};
|
|
|
|
onconnect = function(e) {
|
|
clients.push(e.ports[0]);
|
|
if (clients.length == 1) {
|
|
clients[0].postMessage("Connected");
|
|
} else if (clients.length == 2) {
|
|
broadcast("BothConnected");
|
|
clients[0].onmessage = function(msg) {
|
|
if (msg.data == "StartFetchWithWrongIntegrity") {
|
|
// The fetch will succeed because the integrity value is invalid and we
|
|
// are looking for the console message regarding the bad integrity value.
|
|
fetch("SharedWorker_SRIFailed.html", { integrity: "abc" }).then(
|
|
function() {
|
|
clients[0].postMessage("SRI_failed");
|
|
}
|
|
);
|
|
}
|
|
};
|
|
}
|
|
};
|