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 openedWindows = 0; |
michael@0 | 7 | |
michael@0 | 8 | let winObserver = function(win, topic) { |
michael@0 | 9 | if (topic == "domwindowopened") { |
michael@0 | 10 | win.addEventListener("load", function onLoadWindow() { |
michael@0 | 11 | win.removeEventListener("load", onLoadWindow, false); |
michael@0 | 12 | openedWindows++; |
michael@0 | 13 | if (openedWindows == 2) { |
michael@0 | 14 | ok(false, "Prompt shown."); |
michael@0 | 15 | win.close(); |
michael@0 | 16 | } |
michael@0 | 17 | }, false); |
michael@0 | 18 | } |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | Services.ww.registerNotification(winObserver); |
michael@0 | 22 | |
michael@0 | 23 | let mutObserver = null; |
michael@0 | 24 | |
michael@0 | 25 | loadWebapp("geolocation-prompt-noperm.webapp", undefined, function onLoad() { |
michael@0 | 26 | let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal; |
michael@0 | 27 | let permValue = Services.perms.testExactPermissionFromPrincipal(principal, "geolocation"); |
michael@0 | 28 | is(permValue, Ci.nsIPermissionManager.UNKNOWN_ACTION, "Geolocation permission: unknown."); |
michael@0 | 29 | |
michael@0 | 30 | let msg = gAppBrowser.contentDocument.getElementById("msg"); |
michael@0 | 31 | mutObserver = new MutationObserver(function(mutations) { |
michael@0 | 32 | if (msg.textContent == "Failure.") { |
michael@0 | 33 | ok(true, "Permission not granted."); |
michael@0 | 34 | } else { |
michael@0 | 35 | ok(false, "Permission not granted."); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | finish(); |
michael@0 | 39 | }); |
michael@0 | 40 | mutObserver.observe(msg, { childList: true }); |
michael@0 | 41 | }); |
michael@0 | 42 | |
michael@0 | 43 | registerCleanupFunction(function() { |
michael@0 | 44 | Services.ww.unregisterNotification(winObserver); |
michael@0 | 45 | mutObserver.disconnect(); |
michael@0 | 46 | }); |
michael@0 | 47 | } |