michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let openedWindows = 0; michael@0: michael@0: let winObserver = function(win, topic) { michael@0: if (topic == "domwindowopened") { michael@0: win.addEventListener("load", function onLoadWindow() { michael@0: win.removeEventListener("load", onLoadWindow, false); michael@0: openedWindows++; michael@0: if (openedWindows == 2) { michael@0: ok(true, "Prompt shown."); michael@0: win.close(); michael@0: } michael@0: }, false); michael@0: } michael@0: } michael@0: michael@0: Services.ww.registerNotification(winObserver); michael@0: michael@0: let mutObserver = null; michael@0: michael@0: loadWebapp("geolocation-prompt-perm.webapp", undefined, function onLoad() { michael@0: let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal; michael@0: let permValue = Services.perms.testExactPermissionFromPrincipal(principal, "geolocation"); michael@0: is(permValue, Ci.nsIPermissionManager.PROMPT_ACTION, "Geolocation permission: prompt."); michael@0: michael@0: let msg = gAppBrowser.contentDocument.getElementById("msg"); michael@0: mutObserver = new MutationObserver(function(mutations) { michael@0: if (msg.textContent == "Failure.") { michael@0: ok(true, "Permission not granted."); michael@0: } else { michael@0: ok(false, "Permission not granted."); michael@0: } michael@0: michael@0: if (openedWindows != 2) { michael@0: ok(false, "Prompt not shown."); michael@0: } michael@0: michael@0: finish(); michael@0: }); michael@0: mutObserver.observe(msg, { childList: true }); michael@0: }); michael@0: michael@0: registerCleanupFunction(function() { michael@0: Services.ww.unregisterNotification(winObserver); michael@0: mutObserver.disconnect(); michael@0: }); michael@0: }