From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../web-platform/mozilla/tests/dom/classList.html | 526 +++++++++++++++++++++ .../mozilla/tests/dom/delayed_window_print.html | 39 ++ .../mozilla/tests/dom/dispatch_select_event.html | 35 ++ .../mozilla/tests/dom/focus-invalid-uri-link.html | 63 +++ ...-writable_unlocked_on_tab_close.https.window.js | 70 +++ .../fs-open_writable_after_trigger.sub.html | 45 ++ .../fs-open_writable_then_close_tab.sub.html | 20 + .../mozilla/tests/dom/fs/support/testHelpers.js | 15 + .../mozilla/tests/dom/range-in-two-selections.html | 34 ++ .../tests/dom/throttling/resources/test.html | 5 + .../tests/dom/throttling/resources/throttling.js | 136 ++++++ .../tests/dom/throttling/resources/ws.sub.js | 3 + .../tests/dom/throttling/throttling-1.window.js | 10 + .../tests/dom/throttling/throttling-2.window.js | 11 + .../tests/dom/throttling/throttling-3.window.js | 11 + .../tests/dom/throttling/throttling-4.window.js | 11 + .../dom/throttling/throttling-indexeddb.window.js | 35 ++ .../dom/throttling/throttling-webaudio.window.js | 35 ++ .../dom/throttling/throttling-webrtc.window.js | 35 ++ .../tests/dom/throttling/throttling-ws.window.js | 37 ++ 20 files changed, 1176 insertions(+) create mode 100644 testing/web-platform/mozilla/tests/dom/classList.html create mode 100644 testing/web-platform/mozilla/tests/dom/delayed_window_print.html create mode 100644 testing/web-platform/mozilla/tests/dom/dispatch_select_event.html create mode 100644 testing/web-platform/mozilla/tests/dom/focus-invalid-uri-link.html create mode 100644 testing/web-platform/mozilla/tests/dom/fs/fs-writable_unlocked_on_tab_close.https.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_after_trigger.sub.html create mode 100644 testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_then_close_tab.sub.html create mode 100644 testing/web-platform/mozilla/tests/dom/fs/support/testHelpers.js create mode 100644 testing/web-platform/mozilla/tests/dom/range-in-two-selections.html create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/resources/test.html create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/resources/throttling.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/resources/ws.sub.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-1.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-2.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-3.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-4.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-indexeddb.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-webaudio.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-webrtc.window.js create mode 100644 testing/web-platform/mozilla/tests/dom/throttling/throttling-ws.window.js (limited to 'testing/web-platform/mozilla/tests/dom') diff --git a/testing/web-platform/mozilla/tests/dom/classList.html b/testing/web-platform/mozilla/tests/dom/classList.html new file mode 100644 index 0000000000..21d79f49e3 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/classList.html @@ -0,0 +1,526 @@ + + +Test for the classList element attribute + + +
+ diff --git a/testing/web-platform/mozilla/tests/dom/delayed_window_print.html b/testing/web-platform/mozilla/tests/dom/delayed_window_print.html new file mode 100644 index 0000000000..0bb9977184 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/delayed_window_print.html @@ -0,0 +1,39 @@ + + +Test for delaying window.print() before load + + + + diff --git a/testing/web-platform/mozilla/tests/dom/dispatch_select_event.html b/testing/web-platform/mozilla/tests/dom/dispatch_select_event.html new file mode 100644 index 0000000000..1fb70aa5b1 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/dispatch_select_event.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/testing/web-platform/mozilla/tests/dom/focus-invalid-uri-link.html b/testing/web-platform/mozilla/tests/dom/focus-invalid-uri-link.html new file mode 100644 index 0000000000..5de81c866f --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/focus-invalid-uri-link.html @@ -0,0 +1,63 @@ + + + + + + + diff --git a/testing/web-platform/mozilla/tests/dom/fs/fs-writable_unlocked_on_tab_close.https.window.js b/testing/web-platform/mozilla/tests/dom/fs/fs-writable_unlocked_on_tab_close.https.window.js new file mode 100644 index 0000000000..6e8192aaef --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/fs/fs-writable_unlocked_on_tab_close.https.window.js @@ -0,0 +1,70 @@ +// META: title=Origin private file system used from multiple tabs +// META: script=support/testHelpers.js + +promise_test(async t => { + const bc = new BroadcastChannel("Coordinate writables"); + + function firstReady(win) { + return new Promise(resolve => { + // Blur triggers after the unload event and after window.closed is set + win.onblur = () => { + // Closing the low-level file handle may get stuck, but the unlocking + // request can only be sent to the parent after the handle is closed. + // There is no guarantee when or if the closing will be complete. + // + // Therefore, the content process shutdown does not wait for the + // completion but sets window.closed and calls the unload listeners + // while actually still holding onto some resources. + // + // Since in this test we mainly want to ensure that a file + // does not remain locked indefinitely, we wait for a reasonable amount + // of time before creating a new writable, corresponding roughly to + // a 500ms closing delay. + const timeoutMs = 400; + setTimeout(() => { + resolve(win); + }, timeoutMs); + }; + }); + } + + const firstTabName = "support/fs-open_writable_then_close_tab.sub.html"; + const firstTab = await firstReady(window.open(firstTabName)); + assert_true(firstTab.closed, "Is the first tab already closed?"); + + function secondReady(win) { + return new Promise(resolve => { + bc.onmessage = e => { + if (e.data === "Second window ready!") { + resolve(win); + } + }; + }); + } + + const secondTabName = "support/fs-open_writable_after_trigger.sub.html"; + const secondTab = await secondReady(window.open(secondTabName)); + + let isDone = false; + let childStatus = "Success"; + + const secondSucceeded = new Promise(resolve => { + bc.onmessage = e => { + isDone = true; + if (e.data !== "Success") { + childStatus = e.data; + } + + resolve(); + }; + }); + + bc.postMessage("Create writable in the second window"); + + await secondSucceeded; + assert_true(isDone, "Did the second tab respond?"); + + await fetch_tests_from_window(secondTab); + + assert_equals(childStatus, "Success"); +}, `writable available for other tabs after one tab is closed`); diff --git a/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_after_trigger.sub.html b/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_after_trigger.sub.html new file mode 100644 index 0000000000..b64d97083f --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_after_trigger.sub.html @@ -0,0 +1,45 @@ + + +Child context test(s) + + + + + +
+ + + diff --git a/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_then_close_tab.sub.html b/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_then_close_tab.sub.html new file mode 100644 index 0000000000..098fe83b1f --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/fs/support/fs-open_writable_then_close_tab.sub.html @@ -0,0 +1,20 @@ + + +Child context test(s) + + + + +
+ + + diff --git a/testing/web-platform/mozilla/tests/dom/fs/support/testHelpers.js b/testing/web-platform/mozilla/tests/dom/fs/support/testHelpers.js new file mode 100644 index 0000000000..5cf47435c1 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/fs/support/testHelpers.js @@ -0,0 +1,15 @@ +async function waitUntil(isWaitDone, untilMs, stepMs = 25) { + const startMs = Date.now(); + + return new Promise((resolve, reject) => { + const areWeDoneYet = setInterval(async function() { + if (await isWaitDone()) { + clearInterval(areWeDoneYet); + resolve(); + } else if (Date.now() > startMs + untilMs) { + clearInterval(areWeDoneYet); + reject(new Error("Timed out after " + untilMs + "ms")); + } + }, stepMs); + }); +} diff --git a/testing/web-platform/mozilla/tests/dom/range-in-two-selections.html b/testing/web-platform/mozilla/tests/dom/range-in-two-selections.html new file mode 100644 index 0000000000..a37464d55a --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/range-in-two-selections.html @@ -0,0 +1,34 @@ + + + + + + + + + +One two + + + + diff --git a/testing/web-platform/mozilla/tests/dom/throttling/resources/test.html b/testing/web-platform/mozilla/tests/dom/throttling/resources/test.html new file mode 100644 index 0000000000..7eb9dd1e40 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/resources/test.html @@ -0,0 +1,5 @@ + + + + + diff --git a/testing/web-platform/mozilla/tests/dom/throttling/resources/throttling.js b/testing/web-platform/mozilla/tests/dom/throttling/resources/throttling.js new file mode 100644 index 0000000000..280b0adc0d --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/resources/throttling.js @@ -0,0 +1,136 @@ +function waitForLoad() { + return new Promise(resolve => addEventListener('load', resolve)) + .then(() => delay(10)); +} + +function delay(timeout) { + return new Promise(resolve => step_timeout(() => resolve(), 10)); +} + +function busy(work) { + return delay(10).then(() => new Promise(resolve => { + step_timeout(() => { + let end = performance.now() + work; + while (performance.now() < end) { + + } + + resolve(); + }, 1); + })); +} + +function getThrottlingRate(delay) { + return new Promise(resolve => { + let start = performance.now(); + setTimeout(() => { + let rate = Math.floor((performance.now() - start) / delay); + resolve(rate); + }, delay); + }); +} + +function addElement(t, element, src) { + return new Promise((resolve, reject) => { + let e = document.createElement(element); + e.addEventListener('load', () => resolve(e)); + if (src) { + e.src = src; + } + document.body.appendChild(e); + t.add_cleanup(() => e.remove()); + }); +} + +function inFrame(t) { + return addElement(t, "iframe", "resources/test.html") + .then(frame => delay(10).then(() => Promise.resolve(frame.contentWindow))); +} + +function addWebSocket(t, url) { + return new Promise((resolve, reject) => { + let socket = new WebSocket(url); + socket.onopen = () => { + t.add_cleanup(() => socket.close()); + resolve(); + }; + socket.onerror = reject; + }); +} + +function addRTCPeerConnection(t) { + return new Promise((resolve, reject) => { + let connection = new RTCPeerConnection(); + t.add_cleanup(() => { + connection.close() + }); + + resolve(); + }); +} + +function addIndexedDB(t) { + return new Promise((resolve, reject) => { + let iDBState = { + running: false, + db: null + }; + + let req = indexedDB.open("testDB", 1); + + req.onupgradeneeded = e => { + let db = e.target.result; + let store = db.createObjectStore("testOS", {keyPath: "id"}); + let index = store.createIndex("index", ["col"]); + }; + + req.onsuccess = e => { + let db = iDBState.db = e.target.result; + let store = db.transaction("testOS", "readwrite").objectStore("testOS"); + let ctr = 0; + + iDBState.running = true; + + function putLoop() { + if (!iDBState.running) { + return; + } + + let req = store.put({id: ctr++, col: "foo"}); + req.onsuccess = putLoop; + + if (!iDBState.request) { + iDBState.request = req; + } + } + + putLoop(); + resolve(); + }; + + t.add_cleanup(() => { + iDBState.running = false; + iDBState.db && iDBState.db.close(); + iDBState.db = null; + }); + }); +} + +function addWebAudio(t) { + return new Promise(resolve => { + let context = new (window.AudioContext || window.webkitAudioContext)(); + context.onstatechange = () => (context.state === "running") && resolve(); + + let gain = context.createGain(); + gain.gain.value = 0.1; + gain.connect(context.destination); + + let webaudionode = context.createOscillator(); + webaudionode.type = 'square'; + webaudionode.frequency.value = 440; // value in hertz + webaudionode.connect(gain); + webaudionode.start(); + + t.add_cleanup(() => webaudionode.stop()); + }); +} diff --git a/testing/web-platform/mozilla/tests/dom/throttling/resources/ws.sub.js b/testing/web-platform/mozilla/tests/dom/throttling/resources/ws.sub.js new file mode 100644 index 0000000000..a1ac273a54 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/resources/ws.sub.js @@ -0,0 +1,3 @@ +var __SERVER__NAME = "{{host}}"; +var __PORT = "{{ports[ws][0]}}"; +var __PATH = "echo"; diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-1.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-1.window.js new file mode 100644 index 0000000000..86cefc8a81 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-1.window.js @@ -0,0 +1,10 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => busy(100) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_greater_than(rate, 10, "Timeout wasn't throttled"); + }), "Throttle when all budget has been used."); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-2.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-2.window.js new file mode 100644 index 0000000000..3ccb35dc08 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-2.window.js @@ -0,0 +1,11 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => inFrame(t) + .then(win => win.busy(100) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_greater_than(rate, 10, "Timeout wasn't throttled"); + }), "Throttle iframe when all budget has been used"); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-3.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-3.window.js new file mode 100644 index 0000000000..d1c38bcc12 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-3.window.js @@ -0,0 +1,11 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => inFrame(t) + .then(win => busy(100) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when all budget in parent has been used"); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-4.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-4.window.js new file mode 100644 index 0000000000..b072b51809 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-4.window.js @@ -0,0 +1,11 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => inFrame(t) + .then(win => win.busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle parent when all budget in iframe has been used"); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-indexeddb.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-indexeddb.window.js new file mode 100644 index 0000000000..73c734a584 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-indexeddb.window.js @@ -0,0 +1,35 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => addIndexedDB(t) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open IndexedDB transactions."); + +promise_test(t => inFrame(t) + .then(win => win.addIndexedDB(t)) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open IndexedDB transactions in iframe."); + +promise_test(t => inFrame(t) + .then(win => addIndexedDB(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open IndexedDB transactions in parent."); + +promise_test(t => inFrame(t) + .then(win => win.addIndexedDB(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open IndexedDB transactions in iframe."); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-webaudio.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-webaudio.window.js new file mode 100644 index 0000000000..5cd7193788 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-webaudio.window.js @@ -0,0 +1,35 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => addWebAudio(t) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there is active WebAudio."); + +promise_test(t => inFrame(t) + .then(win => win.addWebAudio(t)) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there is active WebAudio in iframe."); + +promise_test(t => inFrame(t) + .then(win => addWebAudio(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there is active WebAudio in parent."); + +promise_test(t => inFrame(t) + .then(win => win.addWebAudio(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there is active WebAudio in iframe."); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-webrtc.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-webrtc.window.js new file mode 100644 index 0000000000..2842f77e44 --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-webrtc.window.js @@ -0,0 +1,35 @@ +// META: script=resources/throttling.js + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => addRTCPeerConnection(t) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open RTCPeerConnections."); + +promise_test(t => inFrame(t) + .then(win => win.addRTCPeerConnection(t)) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open RTCPeerConnections in iframe."); + +promise_test(t => inFrame(t) + .then(win => addRTCPeerConnection(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open RTCPeerConnections in parent."); + +promise_test(t => inFrame(t) + .then(win => win.addRTCPeerConnection(t) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open RTCPeerConnections in iframe."); diff --git a/testing/web-platform/mozilla/tests/dom/throttling/throttling-ws.window.js b/testing/web-platform/mozilla/tests/dom/throttling/throttling-ws.window.js new file mode 100644 index 0000000000..185654e04d --- /dev/null +++ b/testing/web-platform/mozilla/tests/dom/throttling/throttling-ws.window.js @@ -0,0 +1,37 @@ +// META: script=resources/ws.sub.js +// META: script=resources/throttling.js +let server = "ws://" + __SERVER__NAME + ":" + __PORT + "/" + __PATH; + +setup(() => waitForLoad() + .then(() => "setup done")); + +promise_test(t => addWebSocket(t, server) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open WebSockets."); + +promise_test(t => inFrame(t) + .then(win => win.addWebSocket(t, server)) + .then(() => busy(100)) + .then(() => getThrottlingRate(100)) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle when there are open WebSockets in iframe."); + +promise_test(t => inFrame(t) + .then(win => addWebSocket(t, server) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open WebSockets in parent."); + +promise_test(t => inFrame(t) + .then(win => win.addWebSocket(t, server) + .then(() => win.busy(100)) + .then(() => win.getThrottlingRate(100))) + .then(rate => { + assert_less_than(rate, 10, "Timeout was throttled"); + }), "Don't throttle iframe when there are open WebSockets in iframe."); -- cgit v1.2.3