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