webapprt/test/chrome/browser_alarm.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 Cu.import("resource://gre/modules/Services.jsm");
michael@0 2
michael@0 3 function test() {
michael@0 4 waitForExplicitFinish();
michael@0 5
michael@0 6 let mutObserverAlarmSet = null;
michael@0 7 let mutObserverAlarmFired = null;
michael@0 8
michael@0 9 let alarmSet = false;
michael@0 10
michael@0 11 loadWebapp("alarm.webapp", undefined, function onLoad() {
michael@0 12 let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal;
michael@0 13 let permValue = Services.perms.testExactPermissionFromPrincipal(principal, "alarms");
michael@0 14 is(permValue, Ci.nsIPermissionManager.ALLOW_ACTION, "Alarm permission: allow.");
michael@0 15
michael@0 16 let msgSet = gAppBrowser.contentDocument.getElementById("msgSet");
michael@0 17 mutObserverAlarmSet = new MutationObserver(function(mutations) {
michael@0 18 is(msgSet.textContent, "Success.", "Alarm added.");
michael@0 19 alarmSet = true;
michael@0 20 });
michael@0 21 mutObserverAlarmSet.observe(msgSet, { childList: true });
michael@0 22
michael@0 23 let msgFired = gAppBrowser.contentDocument.getElementById("msgFired");
michael@0 24 mutObserverAlarmFired = new MutationObserver(function(mutations) {
michael@0 25 is(msgFired.textContent, "Alarm fired.", "Alarm fired.");
michael@0 26
michael@0 27 ok(alarmSet, "Alarm set before firing.");
michael@0 28
michael@0 29 finish();
michael@0 30 });
michael@0 31 mutObserverAlarmFired.observe(msgFired, { childList: true });
michael@0 32 });
michael@0 33
michael@0 34 registerCleanupFunction(function() {
michael@0 35 mutObserverAlarmSet.disconnect();
michael@0 36 mutObserverAlarmFired.disconnect();
michael@0 37 });
michael@0 38 }

mercurial