dom/indexedDB/test/browser_permissionsPromptAllow.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /**
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     6 const testPageURL = "http://mochi.test:8888/browser/" +
     7   "dom/indexedDB/test/browser_permissionsPrompt.html";
     8 const notificationID = "indexedDB-permissions-prompt";
    10 function test()
    11 {
    12   waitForExplicitFinish();
    14   PopupNotifications.transitionsEnabled = false;
    16   // We want a prompt.
    17   setPermission(testPageURL, "indexedDB", "allow");
    18   executeSoon(test1);
    19 }
    21 function test1()
    22 {
    23   info("creating tab");
    24   gBrowser.selectedTab = gBrowser.addTab();
    26   gBrowser.selectedBrowser.addEventListener("load", function () {
    27     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    29     setFinishedCallback(function(result, exception) {
    30       ok(result instanceof IDBDatabase,
    31          "First database creation was successful");
    32       ok(!exception, "No exception");
    33       is(getPermission(testPageURL, "indexedDB"),
    34          Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION,
    35          "Correct permission set");
    36       gBrowser.removeCurrentTab();
    37       executeSoon(test2);
    38     });
    40     registerPopupEventHandler("popupshowing", function () {
    41       ok(true, "prompt showing");
    42     });
    43     registerPopupEventHandler("popupshown", function () {
    44       ok(true, "prompt shown");
    45       triggerMainCommand(this);
    46     });
    47     registerPopupEventHandler("popuphidden", function () {
    48       ok(true, "prompt hidden");
    49     });
    51   }, true);
    53   info("loading test page: " + testPageURL);
    54   content.location = testPageURL;
    55 }
    57 function test2()
    58 {
    59   info("creating tab");
    60   gBrowser.selectedTab = gBrowser.addTab();
    62   gBrowser.selectedBrowser.addEventListener("load", function () {
    63     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    65     setFinishedCallback(function(result, exception) {
    66       ok(result instanceof IDBDatabase,
    67          "First database creation was successful");
    68       ok(!exception, "No exception");
    69       is(getPermission(testPageURL, "indexedDB"),
    70          Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION,
    71          "Correct permission set");
    72       gBrowser.removeCurrentTab();
    73       unregisterAllPopupEventHandlers();
    74       removePermission(testPageURL, "indexedDB");
    75       PopupNotifications.transitionsEnabled = true;
    76       executeSoon(finish);
    77     });
    79     registerPopupEventHandler("popupshowing", function () {
    80       ok(false, "Shouldn't show a popup this time");
    81     });
    82     registerPopupEventHandler("popupshown", function () {
    83       ok(false, "Shouldn't show a popup this time");
    84     });
    85     registerPopupEventHandler("popuphidden", function () {
    86       ok(false, "Shouldn't show a popup this time");
    87     });
    89   }, true);
    91   info("loading test page: " + testPageURL);
    92   content.location = testPageURL;
    93 }

mercurial