webapprt/test/chrome/browser_geolocation-prompt-noperm.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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(false, "Prompt shown.");
    15           win.close();
    16         }
    17       }, false);
    18     }
    19   }
    21   Services.ww.registerNotification(winObserver);
    23   let mutObserver = null;
    25   loadWebapp("geolocation-prompt-noperm.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.UNKNOWN_ACTION, "Geolocation permission: unknown.");
    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       finish();
    39     });
    40     mutObserver.observe(msg, { childList: true });
    41   });
    43   registerCleanupFunction(function() {
    44     Services.ww.unregisterNotification(winObserver);
    45     mutObserver.disconnect();
    46   });
    47 }

mercurial