diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/alerts/test/test_principal.html | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/alerts/test/test_principal.html')
-rw-r--r-- | toolkit/components/alerts/test/test_principal.html | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/toolkit/components/alerts/test/test_principal.html b/toolkit/components/alerts/test/test_principal.html deleted file mode 100644 index 74a20dbd7..000000000 --- a/toolkit/components/alerts/test/test_principal.html +++ /dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for Bug 1202933</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> -<p id="display"></p> - -<pre id="test"> -<script class="testbody" type="text/javascript"> - -const Cc = SpecialPowers.Cc; -const Ci = SpecialPowers.Ci; -const Services = SpecialPowers.Services; - -const notifier = Cc["@mozilla.org/alerts-service;1"] - .getService(Ci.nsIAlertsService); - -const chromeScript = SpecialPowers.loadChromeScript(_ => { - Components.utils.import("resource://gre/modules/Services.jsm"); - - addMessageListener("anyXULAlertsVisible", function() { - var windows = Services.wm.getEnumerator("alert:alert"); - return windows.hasMoreElements(); - }); - - addMessageListener("getAlertSource", function() { - var alertWindows = Services.wm.getEnumerator("alert:alert"); - if (!alertWindows) { - return null; - } - var alertWindow = alertWindows.getNext(); - return alertWindow.document.getElementById("alertSourceLabel").getAttribute("value"); - }); -}); - -function notify(alertName, principal) { - return new Promise((resolve, reject) => { - var source; - function observe(subject, topic, data) { - if (topic == "alertclickcallback") { - reject(new Error("Alerts should not be clicked during test")); - } else if (topic == "alertshow") { - source = chromeScript.sendSyncMessage("getAlertSource")[0][0]; - notifier.closeAlert(alertName); - } else { - is(topic, "alertfinished", "Should hide alert"); - resolve(source); - } - } - notifier.showAlertNotification(null, "Notification test", - "Surprise! I'm here to test notifications!", - false, alertName, observe, alertName, - null, null, null, principal); - if (SpecialPowers.Services.appinfo.OS == "Darwin") { - notifier.closeAlert(alertName); - } - }); -} - -function* testNoPrincipal() { - var source = yield notify("noPrincipal", null); - ok(!source, "Should omit source without principal"); -} - -function* testSystemPrincipal() { - var principal = Services.scriptSecurityManager.getSystemPrincipal(); - var source = yield notify("systemPrincipal", principal); - ok(!source, "Should omit source for system principal"); -} - -function* testNullPrincipal() { - var principal = Services.scriptSecurityManager.createNullPrincipal({}); - var source = yield notify("nullPrincipal", principal); - ok(!source, "Should omit source for null principal"); -} - -function* testNodePrincipal() { - var principal = SpecialPowers.wrap(document).nodePrincipal; - var source = yield notify("nodePrincipal", principal); - - var stringBundle = Services.strings.createBundle( - "chrome://alerts/locale/alert.properties" - ); - var localizedSource = stringBundle.formatStringFromName( - "source.label", [principal.URI.hostPort], 1); - is(source, localizedSource, "Should include source for node principal"); -} - -function runTest() { - if (!("@mozilla.org/alerts-service;1" in Cc)) { - todo(false, "Alerts service does not exist in this application"); - return; - } - - if ("@mozilla.org/system-alerts-service;1" in Cc) { - todo(false, "Native alerts service exists in this application"); - return; - } - - ok(true, "Alerts service exists in this application"); - - // sendSyncMessage returns an array of arrays. See the comments in - // test_alerts_noobserve.html and test_SpecialPowersLoadChromeScript.html. - var [[alertsVisible]] = chromeScript.sendSyncMessage("anyXULAlertsVisible"); - ok(!alertsVisible, "Alerts should not be present at the start of the test."); - - add_task(testNoPrincipal); - add_task(testSystemPrincipal); - add_task(testNullPrincipal); - add_task(testNodePrincipal); -} - -runTest(); -</script> -</pre> -</body> -</html> |