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 --- toolkit/components/alerts/test/browser.toml | 4 + .../components/alerts/test/browser_bug1682866.js | 56 +++++++ .../components/alerts/test/file_bug1682866.html | 9 ++ toolkit/components/alerts/test/image.gif | Bin 0 -> 60901 bytes toolkit/components/alerts/test/image.png | Bin 0 -> 2531 bytes toolkit/components/alerts/test/image_server.sjs | 92 ++++++++++++ toolkit/components/alerts/test/mochitest.toml | 28 ++++ toolkit/components/alerts/test/test_alerts.html | 88 +++++++++++ .../alerts/test/test_alerts_noobserve.html | 93 ++++++++++++ .../test/test_alerts_requireinteraction.html | 164 +++++++++++++++++++++ toolkit/components/alerts/test/test_image.html | 117 +++++++++++++++ .../components/alerts/test/test_invalid_utf16.html | 160 ++++++++++++++++++++ .../alerts/test/test_multiple_alerts.html | 99 +++++++++++++ toolkit/components/alerts/test/test_principal.html | 123 ++++++++++++++++ 14 files changed, 1033 insertions(+) create mode 100644 toolkit/components/alerts/test/browser.toml create mode 100644 toolkit/components/alerts/test/browser_bug1682866.js create mode 100644 toolkit/components/alerts/test/file_bug1682866.html create mode 100644 toolkit/components/alerts/test/image.gif create mode 100644 toolkit/components/alerts/test/image.png create mode 100644 toolkit/components/alerts/test/image_server.sjs create mode 100644 toolkit/components/alerts/test/mochitest.toml create mode 100644 toolkit/components/alerts/test/test_alerts.html create mode 100644 toolkit/components/alerts/test/test_alerts_noobserve.html create mode 100644 toolkit/components/alerts/test/test_alerts_requireinteraction.html create mode 100644 toolkit/components/alerts/test/test_image.html create mode 100644 toolkit/components/alerts/test/test_invalid_utf16.html create mode 100644 toolkit/components/alerts/test/test_multiple_alerts.html create mode 100644 toolkit/components/alerts/test/test_principal.html (limited to 'toolkit/components/alerts/test') diff --git a/toolkit/components/alerts/test/browser.toml b/toolkit/components/alerts/test/browser.toml new file mode 100644 index 0000000000..61724f2c12 --- /dev/null +++ b/toolkit/components/alerts/test/browser.toml @@ -0,0 +1,4 @@ +[DEFAULT] + +["browser_bug1682866.js"] +support-files = ["file_bug1682866.html"] diff --git a/toolkit/components/alerts/test/browser_bug1682866.js b/toolkit/components/alerts/test/browser_bug1682866.js new file mode 100644 index 0000000000..24b8b6f7b8 --- /dev/null +++ b/toolkit/components/alerts/test/browser_bug1682866.js @@ -0,0 +1,56 @@ +const baseURL = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "http://example.com" +); + +const alertURL = `${baseURL}file_bug1682866.html`; + +add_task(async function testAlertForceClosed() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + alertURL, + true /* waitForLoad */ + ); + + // Open a second which is in the same process as tab + let secondTabIsLoaded = BrowserTestUtils.waitForNewTab( + gBrowser, + alertURL, + true, + false + ); + + let isSuspendedAfterAlert = await SpecialPowers.spawn( + tab.linkedBrowser.browsingContext, + [alertURL], + url => { + content.open(url); + var utils = SpecialPowers.getDOMWindowUtils(content); + return utils.isInputTaskManagerSuspended; + } + ); + + await secondTabIsLoaded; + + let secondTab = gBrowser.tabs[2]; + + is( + isSuspendedAfterAlert, + Services.prefs.getBoolPref("dom.input_events.canSuspendInBCG.enabled"), + "InputTaskManager should be suspended because alert is opened" + ); + + let alertClosed = BrowserTestUtils.waitForEvent( + tab.linkedBrowser, + "DOMModalDialogClosed" + ); + + BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, "about:newtab"); + + await BrowserTestUtils.browserLoaded(tab.linkedBrowser); + + await alertClosed; + + gBrowser.removeTab(tab); + gBrowser.removeTab(secondTab); +}); diff --git a/toolkit/components/alerts/test/file_bug1682866.html b/toolkit/components/alerts/test/file_bug1682866.html new file mode 100644 index 0000000000..328edcbac5 --- /dev/null +++ b/toolkit/components/alerts/test/file_bug1682866.html @@ -0,0 +1,9 @@ + + + + + diff --git a/toolkit/components/alerts/test/image.gif b/toolkit/components/alerts/test/image.gif new file mode 100644 index 0000000000..053b4d9261 Binary files /dev/null and b/toolkit/components/alerts/test/image.gif differ diff --git a/toolkit/components/alerts/test/image.png b/toolkit/components/alerts/test/image.png new file mode 100644 index 0000000000..430c3c5e65 Binary files /dev/null and b/toolkit/components/alerts/test/image.png differ diff --git a/toolkit/components/alerts/test/image_server.sjs b/toolkit/components/alerts/test/image_server.sjs new file mode 100644 index 0000000000..4caa21ce27 --- /dev/null +++ b/toolkit/components/alerts/test/image_server.sjs @@ -0,0 +1,92 @@ +const CC = Components.Constructor; + +let { setTimeout } = ChromeUtils.importESModule( + "resource://gre/modules/Timer.sys.mjs" +); + +const LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); + +const FileInputStream = CC( + "@mozilla.org/network/file-input-stream;1", + "nsIFileInputStream", + "init" +); + +const BinaryInputStream = CC( + "@mozilla.org/binaryinputstream;1", + "nsIBinaryInputStream", + "setInputStream" +); + +function handleRequest(request, response) { + let params = parseQueryString(request.queryString); + + response.setStatusLine(request.httpVersion, 200, "OK"); + + // Compare and increment a cookie for this request. This is used to test + // private browsing mode; the cookie should not be set if the image is + // loaded anonymously. + if (params.has("c")) { + let expectedValue = parseInt(params.get("c"), 10); + let actualValue = !request.hasHeader("Cookie") + ? 0 + : parseInt( + request.getHeader("Cookie").replace(/^counter=(\d+)/, "$1"), + 10 + ); + if (actualValue != expectedValue) { + response.setStatusLine(request.httpVersion, 400, "Wrong counter value"); + return; + } + response.setHeader("Set-Cookie", `counter=${expectedValue + 1}`, false); + } + + // Wait to send the image if a timeout is given. + let timeout = parseInt(params.get("t"), 10); + if (timeout > 0) { + response.processAsync(); + setTimeout(() => { + respond(params, request, response); + response.finish(); + }, timeout * 1000); + return; + } + + respond(params, request, response); +} + +function parseQueryString(queryString) { + return queryString.split("&").reduce((params, param) => { + let [key, value] = param.split("=", 2); + params.set(key, value); + return params; + }, new Map()); +} + +function respond(params, request, response) { + if (params.has("s")) { + let statusCode = parseInt(params.get("s"), 10); + response.setStatusLine(request.httpVersion, statusCode, "Custom status"); + return; + } + var filename = params.get("f"); + writeFile(filename, response); +} + +function writeFile(name, response) { + var file = new LocalFile(getState("__LOCATION__")).parent; + file.append(name); + + let mimeType = Cc["@mozilla.org/uriloader/external-helper-app-service;1"] + .getService(Ci.nsIMIMEService) + .getTypeFromFile(file); + + let fileStream = new FileInputStream(file, 1, 0, false); + let binaryStream = new BinaryInputStream(fileStream); + + response.setHeader("Content-Type", mimeType, false); + response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available()); + + binaryStream.close(); + fileStream.close(); +} diff --git a/toolkit/components/alerts/test/mochitest.toml b/toolkit/components/alerts/test/mochitest.toml new file mode 100644 index 0000000000..bb6da55f33 --- /dev/null +++ b/toolkit/components/alerts/test/mochitest.toml @@ -0,0 +1,28 @@ +[DEFAULT] +skip-if = ["os == 'android'"] # We don't use XUL alerts on Android +support-files = [ + "image.gif", + "image.png", + "image_server.sjs", +] + +# Synchronous tests like test_alerts.html must come before +# asynchronous tests like test_alerts_noobserve.html! + +["test_alerts.html"] + +["test_alerts_noobserve.html"] + +["test_alerts_requireinteraction.html"] +skip-if = ["verify && os == 'linux'"] + +["test_image.html"] +skip-if = ["verify"] + +["test_invalid_utf16.html"] +run-if = ["os == 'win'"] # Bug 1836526 + +["test_multiple_alerts.html"] + +["test_principal.html"] +skip-if = ["verify"] # Bug 1810860 diff --git a/toolkit/components/alerts/test/test_alerts.html b/toolkit/components/alerts/test/test_alerts.html new file mode 100644 index 0000000000..9c9371fc70 --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts.html @@ -0,0 +1,88 @@ + + + + + Test for Alerts Service + + + + + +

+ +
Alerts service, with observer "synchronous" case. +
+
Did a notification appear anywhere? +
If so, the test will finish once the notification disappears. + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_alerts_noobserve.html b/toolkit/components/alerts/test/test_alerts_noobserve.html new file mode 100644 index 0000000000..b6a7658e17 --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts_noobserve.html @@ -0,0 +1,93 @@ + + + + + Test for Alerts Service + + + + + +

+ +
Alerts service, without observer "asynchronous" case. +
+
A notification should soon appear somewhere. +
If there has been no crash when the notification (later) disappears, assume all is good. + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_alerts_requireinteraction.html b/toolkit/components/alerts/test/test_alerts_requireinteraction.html new file mode 100644 index 0000000000..ca8fa1c9e3 --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts_requireinteraction.html @@ -0,0 +1,164 @@ + + + + Test for alerts with requireInteraction + + + + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_image.html b/toolkit/components/alerts/test/test_image.html new file mode 100644 index 0000000000..3928529c13 --- /dev/null +++ b/toolkit/components/alerts/test/test_image.html @@ -0,0 +1,117 @@ + + + + Test for Bug 1233086 + + + + + +

+ +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_invalid_utf16.html b/toolkit/components/alerts/test/test_invalid_utf16.html new file mode 100644 index 0000000000..a4f862238c --- /dev/null +++ b/toolkit/components/alerts/test/test_invalid_utf16.html @@ -0,0 +1,160 @@ + + + + + + Test for stability when providing invalid UTF-16 strings + + + + + + +

+ +

+
+
+
diff --git a/toolkit/components/alerts/test/test_multiple_alerts.html b/toolkit/components/alerts/test/test_multiple_alerts.html
new file mode 100644
index 0000000000..95843b2e89
--- /dev/null
+++ b/toolkit/components/alerts/test/test_multiple_alerts.html
@@ -0,0 +1,99 @@
+
+
+
+  Test for multiple alerts
+  
+  
+
+
+
+
+
+ + diff --git a/toolkit/components/alerts/test/test_principal.html b/toolkit/components/alerts/test/test_principal.html new file mode 100644 index 0000000000..5464d92977 --- /dev/null +++ b/toolkit/components/alerts/test/test_principal.html @@ -0,0 +1,123 @@ + + + + Test for Bug 1202933 + + + + + +

+ +
+
+
+ + -- cgit v1.2.3