summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/sharedWorker_fetch.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/sharedWorker_fetch.js')
-rw-r--r--dom/serviceworkers/test/sharedWorker_fetch.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/sharedWorker_fetch.js b/dom/serviceworkers/test/sharedWorker_fetch.js
new file mode 100644
index 0000000000..89618c4e83
--- /dev/null
+++ b/dom/serviceworkers/test/sharedWorker_fetch.js
@@ -0,0 +1,30 @@
+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");
+ }
+ );
+ }
+ };
+ }
+};