Bug 1523706 - Extend devtools test. r=ckerschb
authorTom Schuster <evilpies@gmail.com>
Tue, 23 Jul 2019 09:47:03 +0000
changeset 483813 09edf04895b6a18f9f43ac6b55acdb8d2470ea62
parent 483812 122642699fc52ba544bbf33d361c73c1491e1430
child 483814 2e1cf25c76734c9426e146eeee699d38a27db13b
push id36333
push usernerli@mozilla.com
push dateTue, 23 Jul 2019 15:57:48 +0000
treeherdermozilla-central@5b35e2ff7c15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1523706
milestone70.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 1523706 - Extend devtools test. r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D37912
devtools/client/webconsole/test/mochitest/browser_webconsole_non_javascript_mime_worker_error.js
devtools/client/webconsole/test/mochitest/test-non-javascript-mime-worker.html
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_non_javascript_mime_worker_error.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_non_javascript_mime_worker_error.js
@@ -1,27 +1,36 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that importScripts loads inside a worker with a non-JavaScript
 // MIME types produce an error and fail.
 // See Bug 1514680.
+// Also tests that `new Worker` with a non-JS MIME type fails. (Bug 1523706)
 
 "use strict";
 
 const TEST_URI =
   "http://example.com/browser/devtools/client/webconsole/" +
   "test/mochitest/" +
   "test-non-javascript-mime-worker.html";
-const MIME_ERROR_MSG =
-  "Loading script from “http://example.com/browser/devtools/client/webconsole/test/mochitest/test-non-javascript-mime.js” with importScripts() was blocked because of a disallowed MIME type (“text/plain”).";
+
+const JS_URI =
+  "http://example.com/browser/devtools/client/webconsole/test/mochitest/test-non-javascript-mime.js";
+const MIME_ERROR_MSG1 = `Loading Worker from “${JS_URI}” was blocked because of a disallowed MIME type (“text/plain”).`;
+const MIME_ERROR_MSG2 = `Loading script from “${JS_URI}” with importScripts() was blocked because of a disallowed MIME type (“text/plain”).`;
 
 add_task(async function() {
   const hud = await openNewTabAndConsole(TEST_URI);
   await waitFor(
-    () => findMessage(hud, MIME_ERROR_MSG, ".message.error"),
+    () => findMessage(hud, MIME_ERROR_MSG1, ".message.error"),
+    "",
+    100
+  );
+  await waitFor(
+    () => findMessage(hud, MIME_ERROR_MSG2, ".message.error"),
     "",
     100
   );
   ok(true, "MIME type error displayed");
 });
--- a/devtools/client/webconsole/test/mochitest/test-non-javascript-mime-worker.html
+++ b/devtools/client/webconsole/test/mochitest/test-non-javascript-mime-worker.html
@@ -2,19 +2,24 @@
 <html lang="en">
   <head>
     <meta charset="utf-8">
     <title>Web Console test for script with non-JavaScript MIME type</title>
 <!-- Any copyright is dedicated to the Public Domain.
      http://creativecommons.org/publicdomain/zero/1.0/ -->
     <script>
         "use strict";
+
+        // Test new Worker
+        new Worker("http://example.com/browser/devtools/client/webconsole/test/mochitest/test-non-javascript-mime.js");
+
+        // Test importScripts
         const source = `importScripts("http://example.com/browser/devtools/client/webconsole/" +
                                       "test/mochitest/" +
                                       "test-non-javascript-mime.js");`;
         const url = URL.createObjectURL(new Blob([source], {type: "application/javascript"}));
         new Worker(url);
     </script>
   </head>
   <body>
-    <p>Web Console test for importScripts() inside Worker with non-JavaScript MIME type.</p>
+    <p>Web Console test for Worker and importScripts() inside Worker with non-JavaScript MIME type.</p>
   </body>
 </html>