1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/test/browser_permissionsPromptAllow.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +/** 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +const testPageURL = "http://mochi.test:8888/browser/" + 1.10 + "dom/indexedDB/test/browser_permissionsPrompt.html"; 1.11 +const notificationID = "indexedDB-permissions-prompt"; 1.12 + 1.13 +function test() 1.14 +{ 1.15 + waitForExplicitFinish(); 1.16 + 1.17 + PopupNotifications.transitionsEnabled = false; 1.18 + 1.19 + // We want a prompt. 1.20 + setPermission(testPageURL, "indexedDB", "allow"); 1.21 + executeSoon(test1); 1.22 +} 1.23 + 1.24 +function test1() 1.25 +{ 1.26 + info("creating tab"); 1.27 + gBrowser.selectedTab = gBrowser.addTab(); 1.28 + 1.29 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.30 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.31 + 1.32 + setFinishedCallback(function(result, exception) { 1.33 + ok(result instanceof IDBDatabase, 1.34 + "First database creation was successful"); 1.35 + ok(!exception, "No exception"); 1.36 + is(getPermission(testPageURL, "indexedDB"), 1.37 + Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION, 1.38 + "Correct permission set"); 1.39 + gBrowser.removeCurrentTab(); 1.40 + executeSoon(test2); 1.41 + }); 1.42 + 1.43 + registerPopupEventHandler("popupshowing", function () { 1.44 + ok(true, "prompt showing"); 1.45 + }); 1.46 + registerPopupEventHandler("popupshown", function () { 1.47 + ok(true, "prompt shown"); 1.48 + triggerMainCommand(this); 1.49 + }); 1.50 + registerPopupEventHandler("popuphidden", function () { 1.51 + ok(true, "prompt hidden"); 1.52 + }); 1.53 + 1.54 + }, true); 1.55 + 1.56 + info("loading test page: " + testPageURL); 1.57 + content.location = testPageURL; 1.58 +} 1.59 + 1.60 +function test2() 1.61 +{ 1.62 + info("creating tab"); 1.63 + gBrowser.selectedTab = gBrowser.addTab(); 1.64 + 1.65 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.66 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.67 + 1.68 + setFinishedCallback(function(result, exception) { 1.69 + ok(result instanceof IDBDatabase, 1.70 + "First database creation was successful"); 1.71 + ok(!exception, "No exception"); 1.72 + is(getPermission(testPageURL, "indexedDB"), 1.73 + Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION, 1.74 + "Correct permission set"); 1.75 + gBrowser.removeCurrentTab(); 1.76 + unregisterAllPopupEventHandlers(); 1.77 + removePermission(testPageURL, "indexedDB"); 1.78 + PopupNotifications.transitionsEnabled = true; 1.79 + executeSoon(finish); 1.80 + }); 1.81 + 1.82 + registerPopupEventHandler("popupshowing", function () { 1.83 + ok(false, "Shouldn't show a popup this time"); 1.84 + }); 1.85 + registerPopupEventHandler("popupshown", function () { 1.86 + ok(false, "Shouldn't show a popup this time"); 1.87 + }); 1.88 + registerPopupEventHandler("popuphidden", function () { 1.89 + ok(false, "Shouldn't show a popup this time"); 1.90 + }); 1.91 + 1.92 + }, true); 1.93 + 1.94 + info("loading test page: " + testPageURL); 1.95 + content.location = testPageURL; 1.96 +}