mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
60 lines
1.8 KiB
HTML
60 lines
1.8 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for Alerts Service</title>
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
|
|
Alerts service mochitest<br/>
|
|
|
|
Did an alert appear anywhere?<br/>
|
|
If so, the test will finish once the alert disappears. If not, the test will time out.<br/>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
var gReaperTimeoutId;
|
|
var observer = {
|
|
observe: function (aSubject, aTopic, aData) {
|
|
if (aTopic != "alertclickcallback") // Did someone click the alert while running mochitests?...
|
|
is(aTopic, "alertfinished", "Checking the topic for a finished notification");
|
|
|
|
is(aData, "foobarcookie", "Checking whether the alert cookie was passed correctly");
|
|
clearTimeout(gReaperTimeoutId);
|
|
SimpleTest.finish();
|
|
}
|
|
};
|
|
|
|
const kTimeoutSeconds = 15;
|
|
function reaper() {
|
|
ok(false,"Observer is notified within " + kTimeoutSeconds + " seconds")
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
try {
|
|
SimpleTest.waitForExplicitFinish();
|
|
gReaperTimeoutId = setTimeout(reaper, kTimeoutSeconds * 1000);
|
|
var notifier = Cc["@mozilla.org/alerts-service;1"].
|
|
getService(Ci.nsIAlertsService);
|
|
notifier.showAlertNotification(null, "Notification test", "Surprise! I'm here to test notifications!",
|
|
false, "foobarcookie", observer);
|
|
|
|
} catch (ex) {
|
|
// Alerts service doesn't exist
|
|
todo(false, "Alerts service doesn't exist")
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|