summaryrefslogtreecommitdiffstats
path: root/toolkit/components/alerts/test/test_multiple_alerts.html
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
commit0ddd00f1959c78ce37c14fef3c83401408fca3bf (patch)
treed408e02767c86cf8aac3acbb86722b03c77ede6f /toolkit/components/alerts/test/test_multiple_alerts.html
parent20f0905b33cbb18d1caa80c55e2f552c2e18957b (diff)
downloadUXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.gz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.lz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.xz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/alerts/test/test_multiple_alerts.html')
-rw-r--r--toolkit/components/alerts/test/test_multiple_alerts.html103
1 files changed, 0 insertions, 103 deletions
diff --git a/toolkit/components/alerts/test/test_multiple_alerts.html b/toolkit/components/alerts/test/test_multiple_alerts.html
deleted file mode 100644
index 9d939b63a..000000000
--- a/toolkit/components/alerts/test/test_multiple_alerts.html
+++ /dev/null
@@ -1,103 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>Test for multiple alerts</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-const Cc = SpecialPowers.Cc;
-const Ci = SpecialPowers.Ci;
-
-const chromeScript = SpecialPowers.loadChromeScript(_ => {
- Components.utils.import("resource://gre/modules/Services.jsm");
- Components.utils.import("resource://gre/modules/Timer.jsm");
-
- const alertService = Components.classes["@mozilla.org/alerts-service;1"]
- .getService(Components.interfaces.nsIAlertsService);
-
- addMessageListener("waitForPosition", function() {
- var timer = setTimeout(function() {
- Services.ww.unregisterNotification(windowObserver);
- sendAsyncMessage("waitedForPosition", null);
- }, 2000);
-
- var windowObserver = function(aSubject, aTopic, aData) {
- if (aTopic != "domwindowopened") {
- return;
- }
-
- // Alerts are implemented using XUL.
- clearTimeout(timer);
-
- Services.ww.unregisterNotification(windowObserver);
-
- var win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow);
- win.addEventListener("pageshow", function onPageShow() {
- win.removeEventListener("pageshow", onPageShow, false);
-
- var x = win.screenX;
- var y = win.screenY;
-
- win.addEventListener("pagehide", function onPageHide() {
- win.removeEventListener("pagehide", onPageHide, false);
- sendAsyncMessage("waitedForPosition", { x, y });
- }, false);
-
- alertService.closeAlert();
- }, false);
- };
-
- Services.ww.registerNotification(windowObserver);
- });
-});
-
-function promiseAlertPosition(alertService) {
- return new Promise(resolve => {
- chromeScript.addMessageListener("waitedForPosition", function waitedForPosition(result) {
- chromeScript.removeMessageListener("waitedForPosition", waitedForPosition);
- resolve(result);
- });
- chromeScript.sendAsyncMessage("waitForPosition");
-
- alertService.showAlertNotification(null, "title", "body");
- ok(true, "Alert shown.");
- });
-}
-
-add_task(function* test_multiple_alerts() {
- if (!("@mozilla.org/alerts-service;1" in Cc)) {
- todo(false, "Alerts service does not exist in this application.");
- return;
- }
-
- ok(true, "Alerts service exists in this application.");
-
- var alertService;
- try {
- alertService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
- ok(true, "Alerts service is available.");
- } catch (ex) {
- todo(false, "Alerts service is not available.");
- return;
- }
-
- var firstAlertPosition = yield promiseAlertPosition(alertService);
- if (!firstAlertPosition) {
- ok(true, "Platform does not use XUL alerts.");
- return;
- }
-
- var secondAlertPosition = yield promiseAlertPosition(alertService);
- is(secondAlertPosition.x, firstAlertPosition.x, "Second alert should be opened in the same position.");
- is(secondAlertPosition.y, firstAlertPosition.y, "Second alert should be opened in the same position.");
-});
-
-</script>
-</pre>
-</body>
-</html>