Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | } |