Bug 1936085 - Part 2: Use ESM in the URL test. r=smaug,frontend-codestyle-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D231595
This commit is contained in:
@@ -1581,7 +1581,6 @@ const rollouts = [
|
||||
"dom/tests/mochitest/whatwg/test_postMessage_transfer.html",
|
||||
"dom/tests/mochitest/whatwg/test_postMessage_userpass.html",
|
||||
"dom/url/tests/browser_download_after_revoke.js",
|
||||
"dom/url/tests/file_url.jsm",
|
||||
"dom/url/tests/protocol_worker.js",
|
||||
"dom/url/tests/test_unknown_url_origin.html",
|
||||
"dom/url/tests/test_url.html",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[DEFAULT]
|
||||
skip-if = ["os == 'android'"]
|
||||
support-files = [
|
||||
"file_url.jsm",
|
||||
"file_worker_url.jsm",
|
||||
"test_bug883784.jsm",
|
||||
"jsm_url_worker.js",
|
||||
"file_url.sys.mjs",
|
||||
"file_worker_url.sys.mjs",
|
||||
"test_bug883784.sys.mjs",
|
||||
"esm_url_worker.js",
|
||||
"!/dom/workers/test/dom_worker_helper.js",
|
||||
]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
onmessage = function (event) {
|
||||
if (event.data != 0) {
|
||||
var worker = new Worker("jsm_url_worker.js");
|
||||
var worker = new Worker("esm_url_worker.js");
|
||||
worker.onmessage = function (ev) {
|
||||
postMessage(ev.data);
|
||||
};
|
||||
@@ -1,14 +1,12 @@
|
||||
var EXPORTED_SYMBOLS = ["checkFromJSM"];
|
||||
|
||||
function checkFromJSM(ok, is) {
|
||||
var url = new URL("http://www.example.com");
|
||||
is(url.href, "http://www.example.com/", "JSM should have URL");
|
||||
export function checkFromESM(ok, is) {
|
||||
var url = new URL("https://www.example.com");
|
||||
is(url.href, "https://www.example.com/", "ESM should have URL");
|
||||
|
||||
var url2 = new URL("/foobar", url);
|
||||
is(
|
||||
url2.href,
|
||||
"http://www.example.com/foobar",
|
||||
"JSM should have URL - based on another URL"
|
||||
"https://www.example.com/foobar",
|
||||
"ESM should have URL - based on another URL"
|
||||
);
|
||||
|
||||
var blob = new Blob(["a"]);
|
||||
@@ -17,7 +15,7 @@ function checkFromJSM(ok, is) {
|
||||
|
||||
var u = new URL(url);
|
||||
ok(u, "URL created");
|
||||
is(u.origin, "null", "Url doesn't have an origin if created in a JSM");
|
||||
is(u.origin, "null", "Url doesn't have an origin if created in a ESM");
|
||||
|
||||
URL.revokeObjectURL(url);
|
||||
ok(true, "URL is revoked");
|
||||
@@ -1,7 +1,5 @@
|
||||
var EXPORTED_SYMBOLS = ["checkFromJSM"];
|
||||
|
||||
function checkFromJSM(ok, is, finish) {
|
||||
let worker = new ChromeWorker("jsm_url_worker.js");
|
||||
export function checkFromESM(ok, is, finish) {
|
||||
let worker = new ChromeWorker("esm_url_worker.js");
|
||||
worker.onmessage = function (event) {
|
||||
if (event.data.type == "finish") {
|
||||
finish();
|
||||
@@ -1,8 +1,6 @@
|
||||
var EXPORTED_SYMBOLS = ["Test"];
|
||||
|
||||
var Test = {
|
||||
export var Test = {
|
||||
start(ok, is, finish) {
|
||||
let worker = new ChromeWorker("jsm_url_worker.js");
|
||||
let worker = new ChromeWorker("esm_url_worker.js");
|
||||
worker.onmessage = function (event) {
|
||||
if (event.data.type == "status") {
|
||||
ok(event.data.status, event.data.msg);
|
||||
@@ -18,7 +18,7 @@
|
||||
{
|
||||
waitForWorkerFinish();
|
||||
|
||||
const {Test} = ChromeUtils.import("chrome://mochitests/content/chrome/dom/url/tests/test_bug883784.jsm");
|
||||
const {Test} = ChromeUtils.importESModule("chrome://mochitests/content/chrome/dom/url/tests/test_bug883784.sys.mjs");
|
||||
Test.start(ok, is, finish);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
/** Test for URL API. **/
|
||||
// Import our test JSM. We first strip the filename off
|
||||
// the chrome url, then append the jsm filename.
|
||||
// Import our test ESM. We first strip the filename off
|
||||
// the chrome url, then append the filename.
|
||||
var base = /.*\//.exec(window.location.href)[0];
|
||||
const {checkFromJSM} = ChromeUtils.import(base + "file_url.jsm");
|
||||
const {checkFromESM} = ChromeUtils.importESModule(base + "file_url.sys.mjs");
|
||||
|
||||
checkFromJSM(ok, is);
|
||||
checkFromESM(ok, is);
|
||||
|
||||
]]></script>
|
||||
</window>
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const {checkFromJSM} = ChromeUtils.import("chrome://mochitests/content/chrome/dom/url/tests/file_worker_url.jsm");
|
||||
checkFromJSM(ok, is, SimpleTest.finish);
|
||||
const {checkFromESM} = ChromeUtils.importESModule(
|
||||
"chrome://mochitests/content/chrome/dom/url/tests/file_worker_url.sys.mjs"
|
||||
);
|
||||
checkFromESM(ok, is, SimpleTest.finish);
|
||||
}
|
||||
|
||||
]]>
|
||||
|
||||
Reference in New Issue
Block a user