Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 Cu.import("resource://gre/modules/Services.jsm");
3 function test() {
4 waitForExplicitFinish();
6 let openedWindows = 0;
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 }
21 Services.ww.registerNotification(winObserver);
23 let mutObserver = null;
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.");
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 }
38 if (openedWindows != 2) {
39 ok(false, "Prompt not shown.");
40 }
42 finish();
43 });
44 mutObserver.observe(msg, { childList: true });
45 });
47 registerCleanupFunction(function() {
48 Services.ww.unregisterNotification(winObserver);
49 mutObserver.disconnect();
50 });
51 }