summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_non_javascript_mime_worker_error.js
blob: 1e0e031b80a0816ed4b912dc281774f6626b0ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* 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 =
  "https://example.com/browser/devtools/client/webconsole/" +
  "test/browser/" +
  "test-non-javascript-mime-worker.html";

const JS_URI =
  "https://example.com/browser/devtools/client/webconsole/test/browser/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(() => findErrorMessage(hud, MIME_ERROR_MSG1), "", 100);
  await waitFor(() => findErrorMessage(hud, MIME_ERROR_MSG2), "", 100);
  ok(true, "MIME type error displayed");
});