summaryrefslogtreecommitdiffstats
path: root/dom/base/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/base/test/browser.toml2
-rw-r--r--dom/base/test/browser_aboutnewtab_process_selection.js4
-rw-r--r--dom/base/test/file_window_close.html2
-rw-r--r--dom/base/test/fullscreen/browser_fullscreen-bug-1798219.js4
-rw-r--r--dom/base/test/fullscreen/browser_fullscreen-navigation-history-race.js4
-rw-r--r--dom/base/test/fullscreen/browser_fullscreen-navigation-history.js4
-rw-r--r--dom/base/test/fullscreen/browser_fullscreen-window-open-race.js2
-rw-r--r--dom/base/test/fullscreen/file_MozDomFullscreen.html2
-rw-r--r--dom/base/test/fullscreen/file_fullscreen-iframe-middle.html2
-rw-r--r--dom/base/test/fullscreen/file_fullscreen-iframe-top.html2
-rw-r--r--dom/base/test/fullscreen/fullscreen_helpers.js7
-rw-r--r--dom/base/test/fullscreen/test_MozDomFullscreen_event.xhtml2
-rw-r--r--dom/base/test/jsmodules/chrome.toml12
-rw-r--r--dom/base/test/jsmodules/export_star_ambiguous.mjs1
-rw-r--r--dom/base/test/jsmodules/import_ambiguous_export.mjs1
-rw-r--r--dom/base/test/jsmodules/import_ambiguous_export_star.mjs1
-rw-r--r--dom/base/test/jsmodules/import_circular.mjs1
-rw-r--r--dom/base/test/jsmodules/import_circular_1.mjs1
-rw-r--r--dom/base/test/jsmodules/import_no_export.mjs2
-rw-r--r--dom/base/test/jsmodules/import_no_indirect_export.mjs2
-rw-r--r--dom/base/test/jsmodules/importmaps/classic_script.js1
-rw-r--r--dom/base/test/jsmodules/importmaps/mochitest.toml7
-rw-r--r--dom/base/test/jsmodules/importmaps/module_chain_1.mjs2
-rw-r--r--dom/base/test/jsmodules/importmaps/module_chain_2.mjs1
-rw-r--r--dom/base/test/jsmodules/importmaps/module_importMap_with_nonexisting_module.mjs4
-rw-r--r--dom/base/test/jsmodules/importmaps/test_dynamic_importMap_load_completes.html33
-rw-r--r--dom/base/test/jsmodules/importmaps/test_dynamic_importMap_with_external_script.html81
-rw-r--r--dom/base/test/jsmodules/importmaps/test_importMap_with_nonexisting_module.html25
-rw-r--r--dom/base/test/jsmodules/module_a.mjs2
-rw-r--r--dom/base/test/jsmodules/module_b.mjs2
-rw-r--r--dom/base/test/jsmodules/module_c.mjs3
-rw-r--r--dom/base/test/jsmodules/module_d.mjs1
-rw-r--r--dom/base/test/jsmodules/module_e.mjs1
-rw-r--r--dom/base/test/jsmodules/test_import_errorMessage.html40
-rw-r--r--dom/base/test/jsmodules/test_import_errorMessage2.html35
-rw-r--r--dom/base/test/mochitest.toml2
-rw-r--r--dom/base/test/test_bug564863-2.xhtml6
-rw-r--r--dom/base/test/test_content_iterator_subtree_shadow_tree.html290
-rw-r--r--dom/base/test/test_embed_xorigin_document.html5
-rw-r--r--dom/base/test/test_range_bounds.html48
-rw-r--r--dom/base/test/unit/test_xhr_standalone.js5
41 files changed, 596 insertions, 56 deletions
diff --git a/dom/base/test/browser.toml b/dom/base/test/browser.toml
index a68bd2e873..04eca5d1aa 100644
--- a/dom/base/test/browser.toml
+++ b/dom/base/test/browser.toml
@@ -104,7 +104,7 @@ skip-if = ["fission"] # Fails with Fission, and we're unlikely to spend time to
["browser_multiple_popups.js"]
skip-if = [
"os == 'win' && !debug", # Bug 1505235
- "os == 'mac' && !debug", # Bug 1661132 (osx)
+ "apple_catalina", # Bug 1661132 (osx), Bug 1866073
"socketprocess_networking",
]
support-files = ["browser_multiple_popups.html"]
diff --git a/dom/base/test/browser_aboutnewtab_process_selection.js b/dom/base/test/browser_aboutnewtab_process_selection.js
index ad59077105..db0e80acdf 100644
--- a/dom/base/test/browser_aboutnewtab_process_selection.js
+++ b/dom/base/test/browser_aboutnewtab_process_selection.js
@@ -33,7 +33,7 @@ add_task(async function () {
// Open 3 tabs using the preloaded browser.
let tabs = [];
for (let i = 0; i < 3; i++) {
- BrowserOpenTab();
+ BrowserCommands.openTab();
tabs.unshift(gBrowser.selectedTab);
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
@@ -114,7 +114,7 @@ add_task(async function preloaded_state_attribute() {
"Sanity check that the first preloaded browser has the correct attribute"
);
- BrowserOpenTab();
+ BrowserCommands.openTab();
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
// Now check that the tabs have the correct browser attributes set
diff --git a/dom/base/test/file_window_close.html b/dom/base/test/file_window_close.html
index 5adec04ec4..b3bb20d499 100644
--- a/dom/base/test/file_window_close.html
+++ b/dom/base/test/file_window_close.html
@@ -13,7 +13,7 @@
if (history.length == 4) {
// We're coming back from history.
function listener(m) {
- if (m.message.includes("Scripts may not close windows that were not opened by script.")) {
+ if (m.message.includes("Scripts may only close windows that were opened by a script.")) {
SpecialPowers.postConsoleSentinel();
SpecialPowers.pushPrefEnv({ set: [["dom.allow_scripts_to_close_windows", true]]}).then(
function() {
diff --git a/dom/base/test/fullscreen/browser_fullscreen-bug-1798219.js b/dom/base/test/fullscreen/browser_fullscreen-bug-1798219.js
index 2aef23b042..6764ff2009 100644
--- a/dom/base/test/fullscreen/browser_fullscreen-bug-1798219.js
+++ b/dom/base/test/fullscreen/browser_fullscreen-bug-1798219.js
@@ -52,7 +52,7 @@ async function waitAndCheckFullscreenState(aWindow) {
add_task(async () => {
const URL =
- "http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-bug-1798219.html";
+ "https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-bug-1798219.html";
// We need this dummy tab which load the same URL as test tab to keep the
// original content process alive after test page navigates away.
let dummyTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
@@ -90,7 +90,7 @@ add_task(async () => {
await BrowserTestUtils.withNewTab(
{
gBrowser,
- url: "http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-bug-1798219-2.html",
+ url: "https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-bug-1798219-2.html",
},
async function (browser) {
// Open a new window to run the tests, the original window will keep the
diff --git a/dom/base/test/fullscreen/browser_fullscreen-navigation-history-race.js b/dom/base/test/fullscreen/browser_fullscreen-navigation-history-race.js
index 49a48c3177..ab1651fd74 100644
--- a/dom/base/test/fullscreen/browser_fullscreen-navigation-history-race.js
+++ b/dom/base/test/fullscreen/browser_fullscreen-navigation-history-race.js
@@ -54,7 +54,7 @@ function preventBFCache(aBrowsingContext, aPrevent) {
await BrowserTestUtils.withNewTab(
{
gBrowser,
- url: "http://mochi.test:8888/browser/dom/base/test/fullscreen/dummy_page.html",
+ url: "https://example.com/browser/dom/base/test/fullscreen/dummy_page.html",
},
async function (browser) {
// Maybe prevent BFCache on initial page.
@@ -66,7 +66,7 @@ function preventBFCache(aBrowsingContext, aPrevent) {
// Navigate to fullscreen page.
const url = crossOrigin
? "https://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html"
- : "http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html";
+ : "https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html";
const loaded = BrowserTestUtils.browserLoaded(browser, false, url);
BrowserTestUtils.startLoadingURIString(browser, url);
await loaded;
diff --git a/dom/base/test/fullscreen/browser_fullscreen-navigation-history.js b/dom/base/test/fullscreen/browser_fullscreen-navigation-history.js
index c4feb7f641..1b344b7a2f 100644
--- a/dom/base/test/fullscreen/browser_fullscreen-navigation-history.js
+++ b/dom/base/test/fullscreen/browser_fullscreen-navigation-history.js
@@ -54,7 +54,7 @@ function preventBFCache(aBrowsingContext, aPrevent) {
await BrowserTestUtils.withNewTab(
{
gBrowser,
- url: "http://mochi.test:8888/browser/dom/base/test/fullscreen/dummy_page.html",
+ url: "https://example.com/browser/dom/base/test/fullscreen/dummy_page.html",
},
async function (browser) {
// Maybe prevent BFCache on initial page.
@@ -66,7 +66,7 @@ function preventBFCache(aBrowsingContext, aPrevent) {
// Navigate to fullscreen page.
const url = crossOrigin
? "https://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html"
- : "http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html";
+ : "https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html";
const loaded = BrowserTestUtils.browserLoaded(browser, false, url);
BrowserTestUtils.startLoadingURIString(browser, url);
await loaded;
diff --git a/dom/base/test/fullscreen/browser_fullscreen-window-open-race.js b/dom/base/test/fullscreen/browser_fullscreen-window-open-race.js
index 4cf8a3d8c7..95668db542 100644
--- a/dom/base/test/fullscreen/browser_fullscreen-window-open-race.js
+++ b/dom/base/test/fullscreen/browser_fullscreen-window-open-race.js
@@ -27,7 +27,7 @@ add_setup(async function () {
add_task(async () => {
const url =
- "http://mochi.test:8888/browser/dom/base/test/fullscreen/dummy_page.html";
+ "https://example.com/browser/dom/base/test/fullscreen/dummy_page.html";
const name = "foo";
await BrowserTestUtils.withNewTab(
diff --git a/dom/base/test/fullscreen/file_MozDomFullscreen.html b/dom/base/test/fullscreen/file_MozDomFullscreen.html
index f954892706..600d335501 100644
--- a/dom/base/test/fullscreen/file_MozDomFullscreen.html
+++ b/dom/base/test/fullscreen/file_MozDomFullscreen.html
@@ -3,6 +3,6 @@
</head>
<body style="background-color: blue;">
<p>Outer doc</p>
-<iframe id="innerFrame" src="http://mochi.test:8888/"></iframe>
+<iframe id="innerFrame" src="https://example.com/"></iframe>
</body>
</html>
diff --git a/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html b/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html
index b60dea43bf..35b07cfa11 100644
--- a/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html
+++ b/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html
@@ -1,5 +1,5 @@
<div name="div" id="div" style="width: 100px; height: 100px; background: blue;">
<iframe id="iframe" allowfullscreen="yes"
- src="http://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html">
+ src="https://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-inner.html">
</iframe>
</div><br>
diff --git a/dom/base/test/fullscreen/file_fullscreen-iframe-top.html b/dom/base/test/fullscreen/file_fullscreen-iframe-top.html
index dddf4930c2..b61cdc02c3 100644
--- a/dom/base/test/fullscreen/file_fullscreen-iframe-top.html
+++ b/dom/base/test/fullscreen/file_fullscreen-iframe-top.html
@@ -1,5 +1,5 @@
<div name="div" id="div" style="width: 100px; height: 100px; background: red;">
<iframe id="iframe" allowfullscreen="yes"
- src="http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html">
+ src="https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html">
</iframe>
</div><br>
diff --git a/dom/base/test/fullscreen/fullscreen_helpers.js b/dom/base/test/fullscreen/fullscreen_helpers.js
index f097ae316e..41548cf8aa 100644
--- a/dom/base/test/fullscreen/fullscreen_helpers.js
+++ b/dom/base/test/fullscreen/fullscreen_helpers.js
@@ -8,15 +8,14 @@ const TEST_URLS = [
`data:text/html,
<div name="div" id="div" style="width: 100px; height: 100px; background: red;">
<iframe id="iframe" allowfullscreen="yes"
- src="http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html"></iframe>
+ src="https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-iframe-middle.html"></iframe>
</div>`,
// toplevel and inner most iframe are in same process, and middle iframe is
// in a different process.
- // eslint-disable-next-line @microsoft/sdl/no-insecure-url
- `http://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-top.html`,
+ `https://example.org/browser/dom/base/test/fullscreen/file_fullscreen-iframe-top.html`,
// toplevel and middle iframe are in same process, and inner most iframe is
// in a different process.
- `http://mochi.test:8888/browser/dom/base/test/fullscreen/file_fullscreen-iframe-top.html`,
+ `https://example.com/browser/dom/base/test/fullscreen/file_fullscreen-iframe-top.html`,
];
function waitRemoteFullscreenExitEvents(aBrowsingContexts) {
diff --git a/dom/base/test/fullscreen/test_MozDomFullscreen_event.xhtml b/dom/base/test/fullscreen/test_MozDomFullscreen_event.xhtml
index 3041d851ac..6b3d8fada2 100644
--- a/dom/base/test/fullscreen/test_MozDomFullscreen_event.xhtml
+++ b/dom/base/test/fullscreen/test_MozDomFullscreen_event.xhtml
@@ -17,7 +17,7 @@ var gPrevTrusted = SpecialPowers.getBoolPref("full-screen-api.allow-trusted-requ
var newwindow;
// Ensure "fullscreen" permissions are not present on the test URI.
-var uri = Services.io.newURI("http://mochi.test:8888");
+var uri = Services.io.newURI("https://example.com");
var principal = Services.scriptSecurityManager.createContentPrincipal(uri, {});
Services.perms.removeFromPrincipal(principal, "fullscreen");
diff --git a/dom/base/test/jsmodules/chrome.toml b/dom/base/test/jsmodules/chrome.toml
index 82d02ad4df..8b8a614bfb 100644
--- a/dom/base/test/jsmodules/chrome.toml
+++ b/dom/base/test/jsmodules/chrome.toml
@@ -3,11 +3,21 @@ support-files = [
"ambiguous_export.mjs",
"import_ambiguous.mjs",
"import_ambiguous_indirect_export.mjs",
+ "import_ambiguous_export.mjs",
+ "import_ambiguous_export_star.mjs",
+ "import_circular.mjs",
+ "import_circular_1.mjs",
"import_no_export.mjs",
"import_no_indirect_export.mjs",
"exportA1.mjs",
"exportA2.mjs",
"export_ambiguous.mjs",
+ "export_star_ambiguous.mjs",
+ "module_a.mjs",
+ "module_b.mjs",
+ "module_c.mjs",
+ "module_d.mjs",
+ "module_e.mjs",
"module_setRan.mjs",
"module_testSyntax.mjs",
"module_badSyntax.mjs",
@@ -47,6 +57,8 @@ support-files = [
["test_import_errorMessage.html"]
+["test_import_errorMessage2.html"]
+
["test_import_meta_resolve.html"]
["test_importedModuleMemoization.html"]
diff --git a/dom/base/test/jsmodules/export_star_ambiguous.mjs b/dom/base/test/jsmodules/export_star_ambiguous.mjs
new file mode 100644
index 0000000000..35cc979dee
--- /dev/null
+++ b/dom/base/test/jsmodules/export_star_ambiguous.mjs
@@ -0,0 +1 @@
+export * from "./ambiguous_export.mjs";
diff --git a/dom/base/test/jsmodules/import_ambiguous_export.mjs b/dom/base/test/jsmodules/import_ambiguous_export.mjs
new file mode 100644
index 0000000000..f5c12ff086
--- /dev/null
+++ b/dom/base/test/jsmodules/import_ambiguous_export.mjs
@@ -0,0 +1 @@
+import { a } from "./ambiguous_export.mjs";
diff --git a/dom/base/test/jsmodules/import_ambiguous_export_star.mjs b/dom/base/test/jsmodules/import_ambiguous_export_star.mjs
new file mode 100644
index 0000000000..1ee2a56d37
--- /dev/null
+++ b/dom/base/test/jsmodules/import_ambiguous_export_star.mjs
@@ -0,0 +1 @@
+import { a } from "./export_star_ambiguous.mjs";
diff --git a/dom/base/test/jsmodules/import_circular.mjs b/dom/base/test/jsmodules/import_circular.mjs
new file mode 100644
index 0000000000..bb3a46bd5e
--- /dev/null
+++ b/dom/base/test/jsmodules/import_circular.mjs
@@ -0,0 +1 @@
+export { a } from "./import_circular_1.mjs";
diff --git a/dom/base/test/jsmodules/import_circular_1.mjs b/dom/base/test/jsmodules/import_circular_1.mjs
new file mode 100644
index 0000000000..eb7c038c77
--- /dev/null
+++ b/dom/base/test/jsmodules/import_circular_1.mjs
@@ -0,0 +1 @@
+export { a } from "./import_circular.mjs";
diff --git a/dom/base/test/jsmodules/import_no_export.mjs b/dom/base/test/jsmodules/import_no_export.mjs
index 47cabac557..d989498c88 100644
--- a/dom/base/test/jsmodules/import_no_export.mjs
+++ b/dom/base/test/jsmodules/import_no_export.mjs
@@ -1 +1 @@
-import x from "./no_export.mjs";
+import { x } from "./no_export.mjs";
diff --git a/dom/base/test/jsmodules/import_no_indirect_export.mjs b/dom/base/test/jsmodules/import_no_indirect_export.mjs
index dd1ca847fc..bfcdcedbc5 100644
--- a/dom/base/test/jsmodules/import_no_indirect_export.mjs
+++ b/dom/base/test/jsmodules/import_no_indirect_export.mjs
@@ -1,2 +1,2 @@
/* eslint-disable import/default */
-import x from "./no_indirect_export.mjs";
+import { a } from "./no_indirect_export.mjs";
diff --git a/dom/base/test/jsmodules/importmaps/classic_script.js b/dom/base/test/jsmodules/importmaps/classic_script.js
new file mode 100644
index 0000000000..d7ae0be054
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/classic_script.js
@@ -0,0 +1 @@
+// Empty script.
diff --git a/dom/base/test/jsmodules/importmaps/mochitest.toml b/dom/base/test/jsmodules/importmaps/mochitest.toml
index 4229455722..1f95b155ac 100644
--- a/dom/base/test/jsmodules/importmaps/mochitest.toml
+++ b/dom/base/test/jsmodules/importmaps/mochitest.toml
@@ -3,6 +3,9 @@ support-files = [
"bug_1865410_module_a.mjs",
"bug_1865410_module_b.mjs",
"bug_1873417.mjs",
+ "classic_script.js",
+ "module_chain_1.mjs",
+ "module_chain_2.mjs",
"module_importMap_with_external_script_0.mjs",
"module_importMap_with_external_script_1.mjs",
"module_importMap_with_external_script_2.mjs",
@@ -13,6 +16,7 @@ support-files = [
"module_importMap_with_external_script_6.mjs",
"module_importMap_with_external_script_6.mjs^headers^",
"module_importMap_with_external_script_7.mjs",
+ "module_importMap_with_nonexisting_module.mjs",
"bad/module_2.mjs",
"bad/module_3.mjs",
"bad/module_4.mjs",
@@ -31,3 +35,6 @@ support-files = [
["test_bug_1873417.html"]
["test_importMap_with_external_script.html"]
+["test_importMap_with_nonexisting_module.html"]
+["test_dynamic_importMap_with_external_script.html"]
+["test_dynamic_importMap_load_completes.html"]
diff --git a/dom/base/test/jsmodules/importmaps/module_chain_1.mjs b/dom/base/test/jsmodules/importmaps/module_chain_1.mjs
new file mode 100644
index 0000000000..d9515fab7f
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/module_chain_1.mjs
@@ -0,0 +1,2 @@
+// eslint-disable-next-line import/no-unassigned-import
+import {} from "./module_chain_2.mjs";
diff --git a/dom/base/test/jsmodules/importmaps/module_chain_2.mjs b/dom/base/test/jsmodules/importmaps/module_chain_2.mjs
new file mode 100644
index 0000000000..ce12406a76
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/module_chain_2.mjs
@@ -0,0 +1 @@
+loaded = true;
diff --git a/dom/base/test/jsmodules/importmaps/module_importMap_with_nonexisting_module.mjs b/dom/base/test/jsmodules/importmaps/module_importMap_with_nonexisting_module.mjs
new file mode 100644
index 0000000000..4f9981bbe3
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/module_importMap_with_nonexisting_module.mjs
@@ -0,0 +1,4 @@
+/* eslint-disable import/no-unassigned-import, import/no-unresolved */
+// Bareword specifier should be mapped to ./good/module_0.mjs.
+import {} from "bare";
+import * as test from "nonexistingmodule";
diff --git a/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_load_completes.html b/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_load_completes.html
new file mode 100644
index 0000000000..da354c1ca0
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_load_completes.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<head>
+<title>Test script loading complets when there's a dynamicly inserted import map</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+
+<!--
+ This test case used to fail intermittently with some modules never
+ being loaded.
+-->
+
+<script>
+ let loaded = false; // Set by module_chain_2.mjs.
+</script>
+
+<script src="classic_script.js"></script>
+
+<script>
+ const script = document.createElement('script');
+ script.type = 'importmap';
+ script.textContent = `{}`;
+ document.head.appendChild(script);
+</script>
+
+<script src="module_chain_1.mjs" type="module"></script>
+
+<script type="module">
+ ok(loaded, "Expected all modules loaded");
+</script>
+
+<body></body>
diff --git a/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_with_external_script.html b/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_with_external_script.html
new file mode 100644
index 0000000000..b78992fb87
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/test_dynamic_importMap_with_external_script.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<head>
+<title>Test speculative preload of external script doesn't conflict with import map</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+
+<!--
+ These tests check that speculative preloading, which could happen before
+ the import map is installed, doesn't load the wrong modules. This version
+ dynamically inserts the import map script element after speculative
+ preloading has started.
+-->
+
+<script>
+ const script = document.createElement('script');
+ script.type = 'importmap';
+ script.textContent =
+ `{
+ "imports": {
+ "bare": "./good/module_0.mjs",
+ "./bad/module_1.mjs": "./good/module_1.mjs",
+ "./bad/module_2.mjs": "./good/module_2.mjs",
+ "./bad/module_3.mjs": "./good/module_3.mjs",
+ "./bad/module_4.mjs": "./good/module_4.mjs",
+ "./bad/module_7.mjs": "./good/module_7.mjs"
+ }
+ }`;
+ document.head.appendChild(script);
+</script>
+
+<!--
+Test bareword import (not supported before import map installed).
+-->
+<script type="module" src="module_importMap_with_external_script_0.mjs"></script>
+
+<!--
+Test mapping from missing resource to existing resource (not found before
+import map installed).
+-->
+<script type="module" src="module_importMap_with_external_script_1.mjs"></script>
+
+<!--
+Test mapping from one existing resource to another (would load wrong resource before
+import map installed).
+-->
+<script type="module" src="module_importMap_with_external_script_2.mjs"></script>
+
+<!--
+Test mapping from one existing resource to another with circular dependency.
+-->
+<script type="module" src="module_importMap_with_external_script_3.mjs"></script>
+
+<!--
+Test with redirect, script_6.mjs -> script_5.mjs -> script_4.mjs.
+We redirect twice here, as sometimes one redirect can't reproduce the crash
+from bug 1835468.
+-->
+<script type="module" src="module_importMap_with_external_script_6.mjs"></script>
+
+<!--
+Test with async attribute
+-->
+<script type="module" async src="module_importMap_with_external_script_7.mjs"></script>
+
+<script>
+ SimpleTest.waitForExplicitFinish();
+
+ let passCount = 0;
+ const expectedCount = 6;
+
+ function success(name) {
+ ok(true, "Test passed, loaded " + name);
+ passCount++;
+ if (passCount == expectedCount) {
+ SimpleTest.finish();
+ }
+ }
+</script>
+<body></body>
diff --git a/dom/base/test/jsmodules/importmaps/test_importMap_with_nonexisting_module.html b/dom/base/test/jsmodules/importmaps/test_importMap_with_nonexisting_module.html
new file mode 100644
index 0000000000..57cfd5e5a1
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/test_importMap_with_nonexisting_module.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Test an import map with an nonexisting module specifier</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+<script type="importmap">
+{
+ "imports": {
+ "bare": "./good/module_0.mjs"
+ }
+}
+</script>
+
+
+<script>
+ SimpleTest.waitForExplicitFinish();
+
+ window.onerror = (event, src, lineno, colno, error) => {
+ ok(error instanceof TypeError, "Should be a TypeError");
+ SimpleTest.finish();
+ };
+
+</script>
+<script type="module" src="module_importMap_with_nonexisting_module.mjs"></script>
diff --git a/dom/base/test/jsmodules/module_a.mjs b/dom/base/test/jsmodules/module_a.mjs
new file mode 100644
index 0000000000..0b0c3304ff
--- /dev/null
+++ b/dom/base/test/jsmodules/module_a.mjs
@@ -0,0 +1,2 @@
+export var a = 1;
+export var b = 2;
diff --git a/dom/base/test/jsmodules/module_b.mjs b/dom/base/test/jsmodules/module_b.mjs
new file mode 100644
index 0000000000..79da84736d
--- /dev/null
+++ b/dom/base/test/jsmodules/module_b.mjs
@@ -0,0 +1,2 @@
+export var b = 3;
+export var c = 4;
diff --git a/dom/base/test/jsmodules/module_c.mjs b/dom/base/test/jsmodules/module_c.mjs
new file mode 100644
index 0000000000..5a2a7e3e09
--- /dev/null
+++ b/dom/base/test/jsmodules/module_c.mjs
@@ -0,0 +1,3 @@
+/* eslint-disable import/export */
+export * from "./module_a.mjs";
+export * from "./module_b.mjs";
diff --git a/dom/base/test/jsmodules/module_d.mjs b/dom/base/test/jsmodules/module_d.mjs
new file mode 100644
index 0000000000..04dc02d27a
--- /dev/null
+++ b/dom/base/test/jsmodules/module_d.mjs
@@ -0,0 +1 @@
+import { a } from "./module_c.mjs";
diff --git a/dom/base/test/jsmodules/module_e.mjs b/dom/base/test/jsmodules/module_e.mjs
new file mode 100644
index 0000000000..544c424fcb
--- /dev/null
+++ b/dom/base/test/jsmodules/module_e.mjs
@@ -0,0 +1 @@
+import { b } from "./module_c.mjs";
diff --git a/dom/base/test/jsmodules/test_import_errorMessage.html b/dom/base/test/jsmodules/test_import_errorMessage.html
index 6ab0b1dd74..2330b46dd9 100644
--- a/dom/base/test/jsmodules/test_import_errorMessage.html
+++ b/dom/base/test/jsmodules/test_import_errorMessage.html
@@ -8,40 +8,38 @@
let count = 0;
window.onerror = function (event, src, lineno, colno, error) {
- info("window.onerror :" + error.message);
+ info("window.onerror: message: " + error.message);
+ info("window.onerror: src: " + src);
ok(error instanceof SyntaxError, "Should be a SyntaxError.");
- // import_no_indirect_export.mjs and import_ambiguous_indirect_export.mjs
- // are related to indirect import/export.
- if (count < 2) {
- ok(error.message.match("indirect"), "Should contain 'indirect'");
- }
-
- // import_ambiguous_indirect_export.mjs and import_ambiguous.mjs both
- // have ambiguous import/export.
- if (count % 2 === 1) {
- ok(error.message.match("ambiguous"), "Should contain 'ambiguous'");
- }
-
- if (count === 2) {
- ok(!error.message.match("ambiguous") && !error.message.match("indirect"),
- "Should NOT contain 'indirect' nor 'ambiguous'");
+ if (src.match("no_indirect_export.mjs") ||
+ src.match("import_no_export.mjs")) {
+ ok(error.message.match("doesn't provide an export named"));
+ } else if(src.match("export_ambiguous.mjs") ||
+ src.match("import_ambiguous_export_star.mjs") ||
+ src.match("import_ambiguous_export.mjs") ||
+ src.match("import_ambiguous.mjs")) {
+ ok(error.message.match("contains ambiguous star export"));
+ } else if (src.match("import_circular_1.mjs")) {
+ ok(error.message.match("contains circular import"));
+ } else {
+ ok(false, "unknown src " + src);
}
count++;
};
function testLoaded() {
- ok(count === 4, "Should have 4 SynaxErrors thrown.");
+ ok(count === 7, "Should have 7 SynaxErrors thrown.");
SimpleTest.finish();
}
+
</script>
-<!--
-In window.onerror will test the error messages, so if the order is changed,
-the code in window.onerror should be updated as well.
--->
<script type="module" src="import_no_indirect_export.mjs"></script>
<script type="module" src="import_ambiguous_indirect_export.mjs"></script>
+<script type="module" src="import_ambiguous_export_star.mjs"></script>
+<script type="module" src="import_ambiguous_export.mjs"></script>
<script type="module" src="import_no_export.mjs"></script>
<script type="module" src="import_ambiguous.mjs"></script>
+<script type="module" src="import_circular.mjs"></script>
<body onload='testLoaded()'></body>
diff --git a/dom/base/test/jsmodules/test_import_errorMessage2.html b/dom/base/test/jsmodules/test_import_errorMessage2.html
new file mode 100644
index 0000000000..ed4227362e
--- /dev/null
+++ b/dom/base/test/jsmodules/test_import_errorMessage2.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Test to get the filename of the requested module after it has been evaluated</title>
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+ SimpleTest.waitForExplicitFinish();
+
+ let count = 0;
+
+ window.onerror = function (event, src, lineno, colno, error) {
+ info("window.onerror: message: " + error.message);
+ info("window.onerror: src: " + src);
+ ok(error instanceof SyntaxError, "Should be a SyntaxError.");
+
+ if (src.match("module_e.mjs")) {
+ ok(error.message.match("contains ambiguous star export"));
+ } else {
+ ok(false, "unknown src " + src);
+ }
+ count++;
+ };
+
+ function testLoaded() {
+ ok(count === 1, "Should have 1 SynaxError thrown.");
+ SimpleTest.finish();
+ }
+
+</script>
+
+<!--module_c.mjs will be evaluated here-->
+<script type="module" src="module_d.mjs"></script>
+
+<!--module_c.mjs will be linked again here-->
+<script type="module" src="module_e.mjs"></script>
+<body onload='testLoaded()'></body>
diff --git a/dom/base/test/mochitest.toml b/dom/base/test/mochitest.toml
index fb6724e497..a1e7b31a19 100644
--- a/dom/base/test/mochitest.toml
+++ b/dom/base/test/mochitest.toml
@@ -1170,6 +1170,8 @@ skip-if = [
["test_content_iterator_subtree.html"]
+["test_content_iterator_subtree_shadow_tree.html"]
+
["test_copyimage.html"]
skip-if = [
"os == 'android'",
diff --git a/dom/base/test/test_bug564863-2.xhtml b/dom/base/test/test_bug564863-2.xhtml
index 6f338f612d..c860a7f6d7 100644
--- a/dom/base/test/test_bug564863-2.xhtml
+++ b/dom/base/test/test_bug564863-2.xhtml
@@ -55,11 +55,11 @@ SimpleTest.waitForExplicitFinish();
// not when run as a Mochitest plain.
//is(xul_cs.color, "rgb(0, 0, 0)", "xul color " + test);
- attrValue = removed ? null : "";
+ let attrValue = removed ? null : "";
is(xul.id, "", "xul id " + test);
- is(xul.getAttribute("id"), "", "xul getAttribute " + test);
+ is(xul.getAttribute("id"), attrValue, "xul getAttribute " + test);
is($("xul_id"), null, "xul getElementById " + test);
}
@@ -149,7 +149,7 @@ SimpleTest.waitForExplicitFinish();
await new Promise(SimpleTest.executeSoon);
if (mutation) {
is(mutation.target, xul, "target is xul");
- is(xul.getAttribute("id"), "", "xul no longer has id attr");
+ is(xul.getAttribute("id"), null, "xul no longer has id attr");
is(xul.id, "", "xul no longer has id");
xul.id = "other_xul_id";
} else {
diff --git a/dom/base/test/test_content_iterator_subtree_shadow_tree.html b/dom/base/test/test_content_iterator_subtree_shadow_tree.html
new file mode 100644
index 0000000000..033aaf80a7
--- /dev/null
+++ b/dom/base/test/test_content_iterator_subtree_shadow_tree.html
@@ -0,0 +1,290 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test for content subtree iterator with ShadowDOM involved</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" href="/tests/SimpleTest/test.css">
+<script>
+var Cc = SpecialPowers.Cc;
+var Ci = SpecialPowers.Ci;
+function finish() {
+ // The SimpleTest may require usual elements in the template, but they shouldn't be during test.
+ // So, let's create them at end of the test.
+ document.body.innerHTML = '<div id="display"></div><div id="content"></div><pre id="test"></pre>';
+ SimpleTest.finish();
+}
+
+function createContentIterator() {
+ return Cc["@mozilla.org/scriptable-content-iterator;1"]
+ .createInstance(Ci.nsIScriptableContentIterator);
+}
+
+function getNodeDescription(aNode) {
+ if (aNode === undefined) {
+ return "undefine";
+ }
+ if (aNode === null) {
+ return "null";
+ }
+ function getElementDescription(aElement) {
+ if (aElement.host) {
+ aElement = aElement.host;
+ }
+ if (aElement.tagName === "BR") {
+ if (aElement.previousSibling) {
+ return `<br> element after ${getNodeDescription(aElement.previousSibling)}`;
+ }
+ return `<br> element in ${getElementDescription(aElement.parentElement)}`;
+ }
+ let hasHint = aElement == document.body;
+ let tag = `<${aElement.tagName.toLowerCase()}`;
+ if (aElement.getAttribute("id")) {
+ tag += ` id="${aElement.getAttribute("id")}"`;
+ hasHint = true;
+ }
+ if (aElement.getAttribute("class")) {
+ tag += ` class="${aElement.getAttribute("class")}"`;
+ hasHint = true;
+ }
+ if (aElement.getAttribute("type")) {
+ tag += ` type="${aElement.getAttribute("type")}"`;
+ }
+ if (aElement.getAttribute("name")) {
+ tag += ` name="${aElement.getAttribute("name")}"`;
+ }
+ if (aElement.getAttribute("value")) {
+ tag += ` value="${aElement.getAttribute("value")}"`;
+ hasHint = true;
+ }
+ if (aElement.getAttribute("style")) {
+ tag += ` style="${aElement.getAttribute("style")}"`;
+ hasHint = true;
+ }
+ if (hasHint) {
+ return tag + ">";
+ }
+
+ return `${tag}> in ${getElementDescription(aElement.parentElement || aElement.parentNode)}`;
+ }
+ switch (aNode.nodeType) {
+ case aNode.TEXT_NODE:
+ return `text node, "${aNode.wholeText.replace(/\n/g, '\\n')}"`;
+ case aNode.COMMENT_NODE:
+ return `comment node, "${aNode.data.replace(/\n/g, '\\n')}"`;
+ case aNode.ELEMENT_NODE:
+ return getElementDescription(SpecialPowers.unwrap(aNode));
+ default:
+ return "unknown node";
+ }
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function () {
+ let iter = createContentIterator();
+
+ function runTest() {
+ /**
+ * Basic tests with complicated tree.
+ */
+ function check(aIter, aExpectedResult, aDescription) {
+ if (aExpectedResult.length) {
+ is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0],
+ `${aDescription}: currentNode should be the text node immediately after initialization (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(aExpectedResult[0])})`);
+ ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true immediately after initialization`);
+
+ aIter.first();
+ is(SpecialPowers.unwrap(aIter.currentNode), aExpectedResult[0],
+ `${aDescription}: currentNode should be the text node after calling first() (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(aExpectedResult[0])})`);
+ ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true after calling first()`);
+
+ for (let expected of aExpectedResult) {
+ is(SpecialPowers.unwrap(aIter.currentNode), expected,
+ `${aDescription}: currentNode should be the node (got: ${getNodeDescription(aIter.currentNode)}, expected: ${getNodeDescription(expected)})`);
+ ok(!aIter.isDone, `${aDescription}: isDone shouldn't be true when ${getNodeDescription(expected)} is expected`);
+ aIter.next();
+ }
+
+ is(SpecialPowers.unwrap(aIter.currentNode), null,
+ `${aDescription}: currentNode should be null after calling next() finally (got: ${getNodeDescription(aIter.currentNode)}`);
+ ok(aIter.isDone, `${aDescription}: isDone should be true after calling next() finally`);
+ } else {
+ is(SpecialPowers.unwrap(aIter.currentNode), null,
+ `${aDescription}: currentNode should be null immediately after initialization (got: ${getNodeDescription(aIter.currentNode)})`);
+ ok(aIter.isDone, `${aDescription}: isDone should be true immediately after initialization`);
+
+ aIter.first();
+ is(SpecialPowers.unwrap(aIter.currentNode), null,
+ `${aDescription}: currentNode should be null after calling first() (got: ${getNodeDescription(aIter.currentNode)})`);
+ ok(aIter.isDone, `${aDescription}: isDone should be true after calling first()`);
+ }
+ }
+
+ // Structure
+ // <div>OuterText1</div>
+ // <div #host1>
+ // #ShadowRoot
+ // InnerText1
+ // <div>OuterText2</div>
+ // <div #host2>
+ // #ShadowRoot
+ // <div>InnerText2</div>
+ // <div>InnerText3</div>
+ // <div #host3>
+ // #ShadowRoot
+ // <div #host4>
+ // #ShadowRoot
+ // InnerText4
+ // OuterText3
+
+ document.body.innerHTML = `<div id="outerText1">OuterText1</div>` +
+ `<div id="host1"></div>` +
+ `<div id="outerText2">OuterText2</div>` +
+ `<div id="host2"></div>` +
+ `<div id="host3"></div>` +
+ `OuterText3`;
+ const outerText1 = document.getElementById("outerText1");
+ const outerText2 = document.getElementById("outerText2");
+
+ const host1 = document.getElementById("host1");
+ const root1 = host1.attachShadow({mode: "open"});
+ root1.innerHTML = "InnerText1";
+
+ const host2 = document.getElementById("host2");
+ const root2 = host2.attachShadow({mode: "open"});
+ root2.innerHTML = "<div>InnerText2</div><div>InnerText3</div>";
+
+ const host3 = document.getElementById("host3");
+ const root3 = host3.attachShadow({mode: "open"});
+ root3.innerHTML = `<div id="host4"></div>`;
+
+ const host4 = root3.getElementById("host4");
+ const root4 = host4.attachShadow({mode: "open"});
+ root4.innerHTML = "InnerText4";
+
+ /**
+ * Selects the <body> with a range.
+ */
+ range = document.createRange();
+ range.selectNode(document.body);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ check(iter, [document.body], "Initialized with range selecting the <body>");
+
+ /**
+ * Selects all children in the <body> with a range.
+ */
+ range = document.createRange();
+ range.selectNodeContents(document.body);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ check(iter, [outerText1, host1,
+ outerText2, host2,
+ host3, // host4 is a child of host3
+ document.body.lastChild],
+ "Initialized with range selecting all children in the <body>");
+
+ /**
+ * range around elements.
+ */
+ range = document.createRange();
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(outerText1.firstChild, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root1.firstChild, root1.firstChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // outerText1.firstChild is a node without children, so the
+ // next candidate is root1.firstChild, given root1.firstChild
+ // is also the end container which isn't fully contained
+ // by this range, so the iterator returns nothing.
+ check(iter, [], "Initialized with range selecting 'OuterText1 and InnerText1'");
+
+ // From light DOM to Shadow DOM #1
+ range = document.createRange();
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(outerText1, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root1.firstChild, root1.firstChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] outerText1 is a container and it has children, so the first node
+ // is the topmost descendant, which is outerText.firstChild.
+ // [end] The end point of this iteration is also outerText1.firstChild because
+ // it is also the topmost element in the previous node of root1.firstChild.
+ // Iteration #1: outerText1.firstChild as it is the start node
+ check(iter, [outerText1.firstChild], "Initialized with range selecting 'OuterText1 and InnerText1'");
+
+ // From light DOM to Shadow DOM #2
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(outerText1, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root2, root2.childNodes.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] outerText1 is a container and it has children, so the first node
+ // is the topmost descendant, which is outerText.firstChild.
+ // [end] root2 is the container and it has children, so the end node is
+ // the last node of root2, which is root2.lastChild
+ // Iteration #1: outerText1.firstChild, as it's the start node
+ // Iteration #2: host1, as it's next available node after outerText1.firstChild
+ // Iteration #3: outerText2, as it's the next sibiling of host1
+ // Iteration #4: host2, as it's the next sibling of outerText2. Since it's
+ // the ancestor of the end node, so we get into this tree and returns
+ // root2.firstChild here.
+ // Iteration #5: root2.lastChild, as it's the next sibling of root2.firstChild
+ check(iter, [outerText1.firstChild, host1, outerText2, root2.firstChild, root2.lastChild],
+ "Initialized with range selecting 'OuterText1, InnerText1, OuterText2 and InnerText2'");
+
+ // From Shadow DOM to Shadow DOM #1
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(root1.firstChild, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root2.lastChild, root2.lastChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] outerText2 is the start because root1.firstChild doesn't have children,
+ // so we look for next available node which is outerText2.
+ // [end] root2.lastChild is the end container, so we look for previous
+ // nodes and get root2.firstChild
+ // Iteration #1: outerText2, as it's the start node
+ // Iteration #2: host2, as it's the next sibling of outerText2. Since it's
+ // the ancestor of the end node, so we get into this tree and returns
+ // root2.firstChild here.
+ check(iter, [outerText2, root2.firstChild], "Initialized with range selecting 'InnerText1, OuterText2 and InnerText2'");
+
+ // From Shadow DOM to Shadow DOM #2
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(root1, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root2.lastChild, root2.lastChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] root1 is the start container and it has children, so the first node
+ // is the topmost descendant, which is root1.firstChild.
+ // [end] root2.lastChild is the end container, so we look for previous
+ // nodes and get root2.firstChild
+ // Iteration #1: root1.firstChild, as it's the start node
+ // Iteration #2: outerText2, as it's the next available node
+ // Iteration #3: host2, as it's the next sibling of outerText2. Since it's
+ // the ancestor of the end node, so we get into this tree and returns
+ // root2.firstChild here.
+ check(iter, [root1.firstChild, outerText2, root2.firstChild], "Initialized with range selecting 'InnerText1, OuterText2 and InnerText2'");
+
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(root1.firstChild, 1);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(root4.firstChild, root4.firstChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] outerText2 is the start because root1.firstChild doesn't have children,
+ // so we look for next available node which is outerText2.
+ // [end] host2 is the end container, so we look for previous
+ // nodes root4.firstChild and eventually get host2.
+ // Iteration #1: outerText2, as it's the start node
+ // Iteration #2: host2, as it's the next sibling of outerText2
+ check(iter, [outerText2, host2], "Initialized with range selecting 'InnerText1, OuterText2, InnerText2 and InnerText3'");
+
+ // From light to light
+ SpecialPowers.wrap(range).setStartAllowCrossShadowBoundary(outerText1.firstChild, 0);
+ SpecialPowers.wrap(range).setEndAllowCrossShadowBoundary(document.body.lastChild, document.body.lastChild.length);
+ iter.initWithRangeAllowCrossShadowBoundary(Ci.nsIScriptableContentIterator.SUBTREE_ITERATOR, range);
+ // [start] host1 is the start because it's the next available node of
+ // outerText1.firstChild.
+ // [end] host3 is the end because the previous node of document.body.lastChild is host3.
+ // Iteration #1: host1, as it's the start node
+ // Iteration #2: outerText2, as it's the next sibling of host1
+ // Iteration #3: host2, as it's the next sibling of outerText2
+ // Iteration #4: host3, as it's the next sibling of host2
+ check(iter, [host1, outerText2, host2, host3],
+ "Initialized with range selecting 'OuterText1, InnerText1, OuterText2, InnerText2, InnerText3 and OuterText3'");
+
+ finish();
+ }
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.shadowdom.selection_across_boundary.enabled", true]]}, runTest);
+});
+</script>
+</head>
+<body></body>
+</html>
diff --git a/dom/base/test/test_embed_xorigin_document.html b/dom/base/test/test_embed_xorigin_document.html
index 7d4c29aacf..4566d48534 100644
--- a/dom/base/test/test_embed_xorigin_document.html
+++ b/dom/base/test/test_embed_xorigin_document.html
@@ -12,11 +12,6 @@ const testPath = window.location.href.replace("http://mochi.test:8888", "");
const testDir = testPath.substring(0, testPath.lastIndexOf('/') + 1);
add_task(async function() {
- // FIXME: Remove when bug 1658342 is fixed
- await SpecialPowers.pushPrefEnv({
- set: [["fission.remoteObjectEmbed", true]],
- });
-
info("Loading image in embed");
let embed = document.createElement("embed");
document.body.appendChild(embed);
diff --git a/dom/base/test/test_range_bounds.html b/dom/base/test/test_range_bounds.html
index 657d315198..dba687eead 100644
--- a/dom/base/test/test_range_bounds.html
+++ b/dom/base/test/test_range_bounds.html
@@ -38,6 +38,22 @@ function isEmptyRect(rect, name) {
is(rect.height, 0, name+'empty rect should have height = 0');
}
+function getTextBoundingClientRect(node) {
+ const quads = node.getBoxQuads()[0];
+ return DOMRect.fromRect({
+ x: quads.p1.x,
+ y: quads.p1.y,
+ width: quads.p2.x - quads.p1.x,
+ height: quads.p3.y - quads.p2.y
+ });
+}
+
+function sortRectList(rectlist) {
+ return Array.prototype.slice.call(rectlist, 0).sort(function(a, b) {
+ return a.top - b.top || a.left - b.left;
+ });
+}
+
function isEmptyRectList(rectlist, name) {
name = annotateName(name);
is(rectlist.length, 0, name + 'empty rectlist should have zero rects');
@@ -90,6 +106,9 @@ function runATest(obj) {
//convert RectList to a real array
obj.rectList=Array.prototype.slice.call(obj.rectList, 0);
}
+ if (obj.mustSortBeforeComparing) {
+ rectlist = sortRectList(rectlist);
+ }
obj.rectList.forEach(function(r,i) {
is(_getRect(rectlist[i]),_getRect(r),
annotateName(testname+": item at "+i));
@@ -109,11 +128,16 @@ function doTest(){
thirdDiv = root.childNodes[5];
var firstPRect = firstP.getBoundingClientRect(),
spanInFirstPRect = spanInFirstP.getBoundingClientRect(),
+ textInFirstPRect = getTextBoundingClientRect(firstP.firstChild),
+ textInSpanInFirstPRect = getTextBoundingClientRect(spanInFirstP.firstChild),
firstDivRect = firstDiv.getBoundingClientRect(),
+ textInFirstDivRect = getTextBoundingClientRect(firstDiv.firstChild),
spanInFirstDivRect = spanInFirstDiv.getBoundingClientRect(),
+ textInSpanInFirstDivRect = getTextBoundingClientRect(spanInFirstDiv.firstChild),
secondPRect = secondP.getBoundingClientRect(),
secondDivRect = secondDiv.getBoundingClientRect(),
spanInSecondPRect = spanInSecondP.getBoundingClientRect(),
+ textInSpanInSecondPRect = getTextBoundingClientRect(spanInSecondP.firstChild),
spanInSecondDivRect = spanInSecondDiv.getBoundingClientRect(),
spanInSecondDivRectList = spanInSecondDiv.getClientRects();
var widthPerchar = spanInSecondPRect.width / spanInSecondP.firstChild.length;
@@ -132,12 +156,14 @@ function doTest(){
{name:'collapsedAtEndOfTextNode', range:[firstP.firstChild, 6],
rect:[spanInFirstPRect.left, spanInFirstPRect.left,
spanInFirstPRect.top, spanInFirstPRect.bottom, 0, spanInFirstPRect.height]},
- {name:'singleBlockNode', range:[root, 1, root, 2], rect:firstPRect},
+ {name:'singleBlockNode', range:[root, 1, root, 2], rect:firstPRect,
+ rectList:[firstPRect, textInFirstPRect, spanInFirstPRect]},
{name:'twoBlockNodes', range:[root, 1, root, 3],
rect:[firstPRect.left, firstPRect.right, firstPRect.top,
firstDivRect.bottom, firstPRect.width,
firstDivRect.bottom - firstPRect.top],
- rectList:[firstPRect, firstDivRect]},
+ rectList:[firstPRect, textInFirstPRect, textInSpanInFirstPRect,
+ firstDivRect, textInFirstDivRect, textInSpanInFirstDivRect]},
{name:'endOfTextNodeToEndOfAnotherTextNodeInAnotherBlock',
range:[spanInFirstP.firstChild, 1, firstDiv.firstChild, 5],
rect:[spanInFirstDivRect.left - 5*widthPerchar, spanInFirstDivRect.left,
@@ -163,7 +189,7 @@ function doTest(){
rectList:[[spanInSecondPRect.left - 3*widthPerchar, spanInSecondPRect.left,
spanInSecondPRect.top, spanInSecondPRect.bottom, 3 * widthPerchar,
spanInSecondPRect.height],
- spanInSecondPRect,
+ spanInSecondPRect, textInSpanInSecondPRect,
[spanInSecondPRect.right, spanInSecondPRect.right + widthPerchar,
spanInSecondPRect.top, spanInSecondPRect.bottom, widthPerchar,
spanInSecondPRect.height]]}
@@ -228,10 +254,17 @@ function doTest(){
}
function testMixedDir(){
var root = document.getElementById('mixeddir');
+ var bdo = document.getElementById('bdo');
var firstSpan = root.firstElementChild, firstSpanRect=firstSpan.getBoundingClientRect(),
- firstSpanRectList = firstSpan.getClientRects();
+ firstSpanWithInnerTextRectList = Array.from(firstSpan.getClientRects());
+ firstSpanWithInnerTextRectList.push(...bdo.getClientRects());
+
+ // Depending on the font rendering, the order of the rects composing the bdo
+ // element may vary. We need to sort the list of rects before comparing it to
+ // the expected list.
+ firstSpanWithInnerTextRectList = sortRectList(firstSpanWithInnerTextRectList);
runATest({name:'mixeddir',range:[firstSpan.firstChild,0,firstSpan.lastChild,firstSpan.lastChild.length],
- rect: firstSpanRect, rectList:firstSpanRectList});
+ rect: firstSpanRect, rectList:firstSpanWithInnerTextRectList, mustSortBeforeComparing: true});
root = document.getElementById('mixeddir2');
firstSpan = root.firstElementChild;
@@ -271,7 +304,10 @@ function testShadowDOM() {
isnot(rect.height, 0, "Div element inside shadow shouldn't have zero size.");
}
-function test(){
+async function test(){
+ // We use getBoxQuads to get some text nodes bounding rects.
+ await SpecialPowers.pushPrefEnv({"set": [["layout.css.getBoxQuads.enabled", true]]});
+
//test ltr
doTest();
diff --git a/dom/base/test/unit/test_xhr_standalone.js b/dom/base/test/unit/test_xhr_standalone.js
index 94f2d7d642..100027f38a 100644
--- a/dom/base/test/unit/test_xhr_standalone.js
+++ b/dom/base/test/unit/test_xhr_standalone.js
@@ -6,6 +6,10 @@
// in non-window non-Worker context
function run_test() {
+ Services.prefs.setBoolPref(
+ "network.fetch.systemDefaultsToOmittingCredentials",
+ false
+ );
var xhr = new XMLHttpRequest();
xhr.open("GET", "data:,", false);
var exceptionThrown = false;
@@ -13,6 +17,7 @@ function run_test() {
xhr.responseType = "";
xhr.withCredentials = false;
} catch (e) {
+ console.error(e);
exceptionThrown = true;
}
Assert.equal(false, exceptionThrown);