From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- dom/tests/browser/browser.toml | 1 + dom/tests/mochitest/chrome/test_focus.xhtml | 5 +- .../mochitest/general/frameStoragePrevented.html | 4 +- .../mochitest/general/storagePermissionsUtils.js | 133 ++++++++++++++++++--- dom/tests/mochitest/general/test_interfaces.js | 5 +- .../general/test_storagePermissionsReject.html | 2 +- .../general/window_storagePermissions.html | 2 + .../mochitest/general/workerStorageAllowed.js | 131 ++++++++++++++------ .../mochitest/general/workerStoragePrevented.js | 114 +++++++++++++----- dom/tests/mochitest/webcomponents/chrome.toml | 2 +- .../test_custom_element_auto_import.html | 49 ++++++++ .../test_custom_element_ensure_custom_element.html | 55 --------- 12 files changed, 356 insertions(+), 147 deletions(-) create mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html delete mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html (limited to 'dom/tests') diff --git a/dom/tests/browser/browser.toml b/dom/tests/browser/browser.toml index dfb7c2c569..1e9f994488 100644 --- a/dom/tests/browser/browser.toml +++ b/dom/tests/browser/browser.toml @@ -44,6 +44,7 @@ tags = "geolocation" skip-if = ["os != 'mac'"] ["browser_bug1238427.js"] +https_first_disabled = true ["browser_bug1316330.js"] diff --git a/dom/tests/mochitest/chrome/test_focus.xhtml b/dom/tests/mochitest/chrome/test_focus.xhtml index 3e30104af4..ab383c4e1e 100644 --- a/dom/tests/mochitest/chrome/test_focus.xhtml +++ b/dom/tests/mochitest/chrome/test_focus.xhtml @@ -9,10 +9,7 @@ diff --git a/dom/tests/mochitest/general/storagePermissionsUtils.js b/dom/tests/mochitest/general/storagePermissionsUtils.js index cfab2f0a14..b17adab6b4 100644 --- a/dom/tests/mochitest/general/storagePermissionsUtils.js +++ b/dom/tests/mochitest/general/storagePermissionsUtils.js @@ -38,7 +38,11 @@ function runIFrame(url) { return; } - ok(!e.data.match(/^FAILURE/), e.data + " (IFRAME = " + url + ")"); + const isFail = e.data.match(/^FAILURE/); + ok(!isFail, e.data + " (IFRAME = " + url + ")"); + if (isFail) { + reject(e); + } } window.addEventListener("message", onMessage); @@ -57,6 +61,11 @@ function runWorker(url) { ok(!e.data.match(/^FAILURE/), e.data + " (WORKER = " + url + ")"); }); + + worker.addEventListener("error", function (e) { + ok(false, e.data + " (WORKER = " + url + ")"); + reject(e); + }); }); } @@ -130,24 +139,59 @@ function storageAllowed() { ok(false, "getting indexedDB should not throw"); } + const dbName = "db"; + try { var promise = caches.keys(); ok(true, "getting caches didn't throw"); return new Promise((resolve, reject) => { - promise.then( - function () { - ok(location.protocol == "https:", "The promise was not rejected"); - resolve(); - }, - function () { - ok( - location.protocol !== "https:", - "The promise should not have been rejected" - ); - resolve(); - } - ); + const checkCacheKeys = () => { + promise.then( + () => { + ok(location.protocol == "https:", "The promise was not rejected"); + resolve(); + }, + () => { + ok( + location.protocol !== "https:", + "The promise should not have been rejected" + ); + resolve(); + } + ); + }; + + const checkDeleteDbAndTheRest = dbs => { + ok( + dbs.some(elem => elem.name === dbName), + "Expected database should be found" + ); + + const end = indexedDB.deleteDatabase(dbName); + end.onsuccess = checkCacheKeys; + end.onerror = err => { + ok(false, "querying indexedDB databases should not throw"); + reject(err); + }; + }; + + const checkDatabasesAndTheRest = () => { + indexedDB + .databases() + .then(checkDeleteDbAndTheRest) + .catch(err => { + ok(false, "deleting an indexedDB database should not throw"); + reject(err); + }); + }; + + const begin = indexedDB.open(dbName); + begin.onsuccess = checkDatabasesAndTheRest; + begin.onerror = err => { + ok(false, "opening an indexedDB database should not throw"); + reject(err); + }; }); } catch (e) { ok(location.protocol !== "https:", "getting caches should not have thrown"); @@ -184,9 +228,47 @@ function storagePrevented() { try { indexedDB; - ok(false, "getting indexedDB should have thrown"); + ok(true, "getting indexedDB didn't throw"); } catch (e) { - ok(true, "getting indexedDB threw"); + ok(false, "getting indexedDB should not have thrown"); + } + + const dbName = "album"; + + try { + indexedDB.open(dbName); + ok(false, "opening an indexedDB database didn't throw"); + } catch (e) { + ok(true, "opening an indexedDB database threw"); + ok( + e.name == "SecurityError", + "opening indexedDB database emitted a security error" + ); + } + + // Note: Security error is expected to be thrown synchronously. + indexedDB.databases().then( + () => { + ok(false, "querying indexedDB databases didn't reject"); + }, + e => { + ok(true, "querying indexedDB databases rejected"); + ok( + e.name == "SecurityError", + "querying indexedDB databases emitted a security error" + ); + } + ); + + try { + indexedDB.deleteDatabase(dbName); + ok(false, "deleting an indexedDB database didn't throw"); + } catch (e) { + ok(true, "deleting an indexedDB database threw"); + ok( + e.name == "SecurityError", + "deleting indexedDB database emitted a security error" + ); } try { @@ -260,8 +342,15 @@ async function runTestInWindow(test) { }; }); - await new Promise(resolve => { + return new Promise((resolve, reject) => { onmessage = e => { + if (!e.data.type) { + w.postMessage("FAILURE: " + e.data, document.referrer); + ok(false, "No error data type"); + reject(e); + return; + } + if (e.data.type == "finish") { w.close(); resolve(); @@ -269,7 +358,15 @@ async function runTestInWindow(test) { } if (e.data.type == "check") { - ok(e.data.test, e.data.msg); + const payload = e.data.msg ? e.data.msg : e.data; + ok(e.data.test, payload); + const isFail = payload.match(/^FAILURE/) || !e.data.test; + if (isFail) { + w.postMessage("FAILURE: " + e.data, document.referrer); + ok(false, payload); + w.close(); + reject(e); + } return; } diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index e6ea910e14..93a26b9238 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -73,6 +73,7 @@ let wasmGlobalInterfaces = [ { name: "Function", insecureContext: true, nightly: true }, { name: "Exception", insecureContext: true }, { name: "Tag", insecureContext: true }, + { name: "JSTag", insecureContext: true, earlyBetaOrEarlier: true }, { name: "compile", insecureContext: true }, { name: "compileStreaming", insecureContext: true }, { name: "instantiate", insecureContext: true }, @@ -256,7 +257,7 @@ let interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "ClipboardEvent", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - { name: "ClipboardItem", earlyBetaOrEarlier: true }, + { name: "ClipboardItem" }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "CloseEvent", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! @@ -328,7 +329,7 @@ let interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "CSSRuleList", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - { name: "CSSStartingStyleRule", insecureContext: true, disabled: true }, + { name: "CSSStartingStyleRule", insecureContext: true, nightly: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "CSSStyleDeclaration", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/tests/mochitest/general/test_storagePermissionsReject.html b/dom/tests/mochitest/general/test_storagePermissionsReject.html index 70dbe856d9..62c06a0639 100644 --- a/dom/tests/mochitest/general/test_storagePermissionsReject.html +++ b/dom/tests/mochitest/general/test_storagePermissionsReject.html @@ -35,7 +35,7 @@ task(async function() { await runIFrame(thirdparty + "frameStorageChrome.html?allowed=no&blockSessionStorage=yes"); // Workers should be unable to access storage - await runWorker("workerStoragePrevented.js"); + await runWorker("workerStoragePrevented.js#outer"); }); }); diff --git a/dom/tests/mochitest/general/window_storagePermissions.html b/dom/tests/mochitest/general/window_storagePermissions.html index 3bab23c13b..92078f2fcc 100644 --- a/dom/tests/mochitest/general/window_storagePermissions.html +++ b/dom/tests/mochitest/general/window_storagePermissions.html @@ -25,6 +25,8 @@ onmessage = e => { let runnable = eval(runnableStr); // eslint-disable-line no-eval runnable.call(this).then(_ => { opener.postMessage({ type: "finish" }, "*"); + }).catch(e => { + ok(false, e.data); }); return; diff --git a/dom/tests/mochitest/general/workerStorageAllowed.js b/dom/tests/mochitest/general/workerStorageAllowed.js index 89e0a4b9ce..93c4c94c48 100644 --- a/dom/tests/mochitest/general/workerStorageAllowed.js +++ b/dom/tests/mochitest/general/workerStorageAllowed.js @@ -14,50 +14,88 @@ function finishTest() { self.close(); } -// Workers don't have access to localstorage or sessionstorage -ok(typeof self.localStorage == "undefined", "localStorage should be undefined"); -ok( - typeof self.sessionStorage == "undefined", - "sessionStorage should be undefined" -); - // Make sure that we can access indexedDB -try { - indexedDB; - ok(true, "WORKER getting indexedDB didn't throw"); -} catch (e) { - ok(false, "WORKER getting indexedDB should not throw"); +function idbTest() { + try { + indexedDB; + + const idbcycle = new Promise((resolve, reject) => { + const begin = indexedDB.open("door"); + begin.onerror = e => { + reject(e); + }; + begin.onsuccess = () => { + indexedDB + .databases() + .then(dbs => { + ok( + dbs.some(elem => elem.name === "door"), + "WORKER just created database should be found" + ); + const end = indexedDB.deleteDatabase("door"); + end.onerror = e => { + reject(e); + }; + end.onsuccess = () => { + resolve(); + }; + }) + .catch(err => { + reject(err); + }); + }; + }); + + idbcycle.then( + () => { + ok(true, "WORKER getting indexedDB didn't throw"); + cacheTest(); + }, + e => { + ok(false, "WORKER getting indexedDB threw " + e.message); + cacheTest(); + } + ); + } catch (e) { + ok(false, "WORKER getting indexedDB should not throw"); + cacheTest(); + } } // Make sure that we can access caches -try { - var promise = caches.keys(); - ok(true, "WORKER getting caches didn't throw"); +function cacheTest() { + try { + var promise = caches.keys(); + ok(true, "WORKER getting caches didn't throw"); - promise.then( - function () { - ok(location.protocol == "https:", "WORKER The promise was not rejected"); - workerTest(); - }, - function () { - ok( - location.protocol !== "https:", - "WORKER The promise should not have been rejected" - ); - workerTest(); - } - ); -} catch (e) { - ok( - location.protocol !== "https:", - "WORKER getting caches should not have thrown" - ); - workerTest(); + promise.then( + function () { + ok( + location.protocol == "https:", + "WORKER The promise was not rejected" + ); + workerTest(); + }, + function () { + ok( + location.protocol !== "https:", + "WORKER The promise should not have been rejected" + ); + workerTest(); + } + ); + } catch (e) { + ok( + location.protocol !== "https:", + "WORKER getting caches should not have thrown" + ); + workerTest(); + } } // Try to spawn an inner worker, and make sure that it can also access storage function workerTest() { - if (location.hash == "#inner") { + if (location.hash != "#outer") { // Don't recurse infinitely, if we are the inner worker, don't spawn another finishTest(); return; @@ -75,4 +113,27 @@ function workerTest() { e.data + " (WORKER = workerStorageAllowed.js#inner)" ); }); + + worker.addEventListener("error", function (e) { + ok(false, e.data + " (WORKER = workerStorageAllowed.js#inner)"); + + finishTest(); + }); +} + +try { + // Workers don't have access to localstorage or sessionstorage + ok( + typeof self.localStorage == "undefined", + "localStorage should be undefined" + ); + ok( + typeof self.sessionStorage == "undefined", + "sessionStorage should be undefined" + ); + + idbTest(); +} catch (e) { + ok(false, "WORKER Unwelcome exception received"); + finishTest(); } diff --git a/dom/tests/mochitest/general/workerStoragePrevented.js b/dom/tests/mochitest/general/workerStoragePrevented.js index 467cc09113..7d232d65df 100644 --- a/dom/tests/mochitest/general/workerStoragePrevented.js +++ b/dom/tests/mochitest/general/workerStoragePrevented.js @@ -21,40 +21,94 @@ ok( "sessionStorage should be undefined" ); -// Make sure that we can't access indexedDB +// Make sure that we can access indexedDB handle try { indexedDB; - ok(false, "WORKER getting indexedDB should have thrown"); + ok(true, "WORKER getting indexedDB didn't throw"); } catch (e) { - ok(true, "WORKER getting indexedDB threw"); + ok(false, "WORKER getting indexedDB threw"); +} + +// Make sure that we cannot access indexedDB methods +idbOpenTest(); + +// Make sure that we can't access indexedDB deleteDatabase +function idbDeleteTest() { + try { + indexedDB.deleteDatabase("door"); + ok(false, "WORKER deleting indexedDB database succeeded"); + } catch (e) { + ok(true, "WORKER deleting indexedDB database failed"); + ok( + e.name == "SecurityError", + "WORKER deleting indexedDB database threw a security error" + ); + } finally { + cacheTest(); + } +} + +// Make sure that we can't access indexedDB databases +function idbDatabasesTest() { + indexedDB + .databases() + .then(() => { + ok(false, "WORKER querying indexedDB databases succeeded"); + }) + .catch(e => { + ok(true, "WORKER querying indexedDB databases failed"); + ok( + e.name == "SecurityError", + "WORKER querying indexedDB databases threw a security error" + ); + }) + .finally(idbDeleteTest); +} + +// Make sure that we can't access indexedDB open +function idbOpenTest() { + try { + indexedDB.open("door"); + ok(false, "WORKER opening indexedDB database succeeded"); + } catch (e) { + ok(true, "WORKER opening indexedDB database failed"); + ok( + e.name == "SecurityError", + "WORKER opening indexedDB database threw a security error" + ); + } finally { + idbDatabasesTest(); + } } // Make sure that we can't access caches -try { - var promise = caches.keys(); - ok(true, "WORKER getting caches didn't throw"); +function cacheTest() { + try { + var promise = caches.keys(); + ok(true, "WORKER getting caches didn't throw"); - promise.then( - function () { - ok(false, "WORKER The promise should have rejected"); - workerTest(); - }, - function () { - ok(true, "WORKER The promise was rejected"); - workerTest(); - } - ); -} catch (e) { - ok( - location.protocol !== "https:", - "WORKER getting caches should not have thrown" - ); - workerTest(); + promise.then( + function () { + ok(false, "WORKER The promise should have rejected"); + workerTest(); + }, + function () { + ok(true, "WORKER The promise was rejected"); + workerTest(); + } + ); + } catch (e) { + ok( + location.protocol !== "https:", + "WORKER getting caches should not have thrown" + ); + workerTest(); + } } // Try to spawn an inner worker, and make sure that it also can't access storage function workerTest() { - if (location.hash == "#inner") { + if (location.hash != "#outer") { // Don't recurse infinitely, if we are the inner worker, don't spawn another finishTest(); return; @@ -62,14 +116,16 @@ function workerTest() { // Create the inner worker, and listen for test messages from it var worker = new Worker("workerStoragePrevented.js#inner"); worker.addEventListener("message", function (e) { - if (e.data == "done") { + const isFail = e.data.match(/^FAILURE/); + ok(!isFail, e.data + " (WORKER = workerStoragePrevented.js#inner)"); + + if (e.data == "done" || isFail) { finishTest(); - return; } + }); + worker.addEventListener("error", function (e) { + ok(false, e.data + " (WORKER = workerStoragePrevented.js#inner)"); - ok( - !e.data.match(/^FAILURE/), - e.data + " (WORKER = workerStoragePrevented.js#inner)" - ); + finishTest(); }); } diff --git a/dom/tests/mochitest/webcomponents/chrome.toml b/dom/tests/mochitest/webcomponents/chrome.toml index b29df619c4..5db7f14a37 100644 --- a/dom/tests/mochitest/webcomponents/chrome.toml +++ b/dom/tests/mochitest/webcomponents/chrome.toml @@ -1,7 +1,7 @@ [DEFAULT] support-files = ["dummy_page.html"] -["test_custom_element_ensure_custom_element.html"] +["test_custom_element_auto_import.html"] ["test_custom_element_htmlconstructor_chrome.html"] support-files = [ diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html b/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html new file mode 100644 index 0000000000..2371600677 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html @@ -0,0 +1,49 @@ + + + + + Test for custom element auto import behavior + + + + + +

+ +

+
+
diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html b/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html
deleted file mode 100644
index 03ed2e3815..0000000000
--- a/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-  
-
-  
-  Test for customElements.ensureCustomElement
-  
-  
-  
-
-
-

- -

-
-
-- 
cgit v1.2.3