Bug 1333573 P8 Update test_chromeWorkerJSM.xul to expect synchronous SecurityError. r=baku
authorBen Kelly <ben@wanderview.com>
Tue, 07 Feb 2017 10:28:39 -0500
changeset 387842 22f07bddd55a293afb3a050e4c4343a13558d19a
parent 387841 7dd9da392d9331452f2c31b50b2cc304754fee63
child 387843 a71128968beeea03a6f6ef71eba36901f678febb
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1333573
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1333573 P8 Update test_chromeWorkerJSM.xul to expect synchronous SecurityError. r=baku
dom/workers/test/WorkerTest_badworker.js
dom/workers/test/WorkerTest_subworker.js
--- a/dom/workers/test/WorkerTest_badworker.js
+++ b/dom/workers/test/WorkerTest_badworker.js
@@ -1,7 +1,1 @@
-/**
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-onmessage = function(event) {
-  throw "Shouldn't be able to read this!";
-}
+// doesn't matter what is in here if the URL is bad
--- a/dom/workers/test/WorkerTest_subworker.js
+++ b/dom/workers/test/WorkerTest_subworker.js
@@ -16,28 +16,18 @@ onmessage = function(event) {
   xhr.open("GET", mochitestURL, false);
   xhr.send();
 
   if (!xhr.responseText) {
     throw "Can't load script file via XHR!";
   }
 
   // We shouldn't be able to make a ChromeWorker to a non-chrome URL.
-  let worker = new ChromeWorker(mochitestURL);
-  worker.onmessage = function(event) {
-    throw event.data;
-  };
-  worker.onerror = function(event) {
-    event.preventDefault();
-
-    // And we shouldn't be able to make a regular Worker to a non-chrome URL.
-    worker = new Worker(mochitestURL);
-    worker.onmessage = function(event) {
-      throw event.data;
-    };
-    worker.onerror = function(event) {
-      event.preventDefault();
+  try{
+    new ChromeWorker(mochitestURL);
+  } catch(e) {
+    if (e.name === 'SecurityError') {
       postMessage("Done");
-    };
-    worker.postMessage("Hi");
-  };
-  worker.postMessage("Hi");
+      return;
+    }
+  }
+  throw('creating a chrome worker with a bad URL should throw a SecurityError');
 };