|
1 Cu.import("resource://gre/modules/Services.jsm"); |
|
2 |
|
3 function test() { |
|
4 waitForExplicitFinish(); |
|
5 |
|
6 let openedWindows = 0; |
|
7 |
|
8 let winObserver = function(win, topic) { |
|
9 if (topic == "domwindowopened") { |
|
10 win.addEventListener("load", function onLoadWindow() { |
|
11 win.removeEventListener("load", onLoadWindow, false); |
|
12 openedWindows++; |
|
13 if (openedWindows == 2) { |
|
14 ok(true, "Prompt shown."); |
|
15 win.close(); |
|
16 } |
|
17 }, false); |
|
18 } |
|
19 } |
|
20 |
|
21 Services.ww.registerNotification(winObserver); |
|
22 |
|
23 let mutObserver = null; |
|
24 |
|
25 loadWebapp("geolocation-prompt-perm.webapp", undefined, function onLoad() { |
|
26 let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal; |
|
27 let permValue = Services.perms.testExactPermissionFromPrincipal(principal, "geolocation"); |
|
28 is(permValue, Ci.nsIPermissionManager.PROMPT_ACTION, "Geolocation permission: prompt."); |
|
29 |
|
30 let msg = gAppBrowser.contentDocument.getElementById("msg"); |
|
31 mutObserver = new MutationObserver(function(mutations) { |
|
32 if (msg.textContent == "Failure.") { |
|
33 ok(true, "Permission not granted."); |
|
34 } else { |
|
35 ok(false, "Permission not granted."); |
|
36 } |
|
37 |
|
38 if (openedWindows != 2) { |
|
39 ok(false, "Prompt not shown."); |
|
40 } |
|
41 |
|
42 finish(); |
|
43 }); |
|
44 mutObserver.observe(msg, { childList: true }); |
|
45 }); |
|
46 |
|
47 registerCleanupFunction(function() { |
|
48 Services.ww.unregisterNotification(winObserver); |
|
49 mutObserver.disconnect(); |
|
50 }); |
|
51 } |