1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/test/browser_permissionsPromptDeny.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 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 + // We want the prompt. 1.17 + PopupNotifications.transitionsEnabled = false; 1.18 + setPermission(testPageURL, "indexedDB", "allow"); 1.19 + executeSoon(test1); 1.20 +} 1.21 + 1.22 +function test1() 1.23 +{ 1.24 + info("creating tab"); 1.25 + gBrowser.selectedTab = gBrowser.addTab(); 1.26 + 1.27 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.28 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.29 + 1.30 + setFinishedCallback(function(result, exception) { 1.31 + ok(!result, "No database created"); 1.32 + is(exception, "InvalidStateError", "Correct exception"); 1.33 + is(getPermission(testPageURL, "indexedDB"), 1.34 + Components.interfaces.nsIPermissionManager.DENY_ACTION, 1.35 + "Correct permission set"); 1.36 + gBrowser.removeCurrentTab(); 1.37 + executeSoon(test2); 1.38 + }); 1.39 + 1.40 + registerPopupEventHandler("popupshowing", function () { 1.41 + ok(true, "prompt showing"); 1.42 + }); 1.43 + registerPopupEventHandler("popupshown", function () { 1.44 + ok(true, "prompt shown"); 1.45 + triggerSecondaryCommand(this, 0); 1.46 + }); 1.47 + registerPopupEventHandler("popuphidden", function () { 1.48 + ok(true, "prompt hidden"); 1.49 + }); 1.50 + 1.51 + }, true); 1.52 + 1.53 + info("loading test page: " + testPageURL); 1.54 + content.location = testPageURL; 1.55 +} 1.56 + 1.57 +function test2() 1.58 +{ 1.59 + info("creating tab"); 1.60 + gBrowser.selectedTab = gBrowser.addTab(); 1.61 + gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true; 1.62 + 1.63 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.64 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.65 + 1.66 + setFinishedCallback(function(result, exception) { 1.67 + ok(!result, "No database created"); 1.68 + is(exception, "InvalidStateError", "Correct exception"); 1.69 + is(getPermission(testPageURL, "indexedDB"), 1.70 + Components.interfaces.nsIPermissionManager.DENY_ACTION, 1.71 + "Correct permission set"); 1.72 + gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false; 1.73 + unregisterAllPopupEventHandlers(); 1.74 + gBrowser.removeCurrentTab(); 1.75 + PopupNotifications.transitionsEnabled = true; 1.76 + executeSoon(test3); 1.77 + }); 1.78 + 1.79 + registerPopupEventHandler("popupshowing", function () { 1.80 + ok(false, "prompt showing"); 1.81 + }); 1.82 + registerPopupEventHandler("popupshown", function () { 1.83 + ok(false, "prompt shown"); 1.84 + }); 1.85 + registerPopupEventHandler("popuphidden", function () { 1.86 + ok(false, "prompt hidden"); 1.87 + }); 1.88 + 1.89 + }, true); 1.90 + 1.91 + info("loading test page: " + testPageURL); 1.92 + content.location = testPageURL; 1.93 +} 1.94 + 1.95 +function test3() 1.96 +{ 1.97 + info("creating tab"); 1.98 + gBrowser.selectedTab = gBrowser.addTab(); 1.99 + 1.100 + gBrowser.selectedBrowser.addEventListener("load", function () { 1.101 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.102 + 1.103 + setFinishedCallback(function(result, exception) { 1.104 + ok(!result, "No database created"); 1.105 + is(exception, "InvalidStateError", "Correct exception"); 1.106 + is(getPermission(testPageURL, "indexedDB"), 1.107 + Components.interfaces.nsIPermissionManager.DENY_ACTION, 1.108 + "Correct permission set"); 1.109 + gBrowser.removeCurrentTab(); 1.110 + unregisterAllPopupEventHandlers(); 1.111 + removePermission(testPageURL, "indexedDB"); 1.112 + executeSoon(finish); 1.113 + }); 1.114 + 1.115 + registerPopupEventHandler("popupshowing", function () { 1.116 + ok(false, "Shouldn't show a popup this time"); 1.117 + }); 1.118 + registerPopupEventHandler("popupshown", function () { 1.119 + ok(false, "Shouldn't show a popup this time"); 1.120 + }); 1.121 + registerPopupEventHandler("popuphidden", function () { 1.122 + ok(false, "Shouldn't show a popup this time"); 1.123 + }); 1.124 + 1.125 + }, true); 1.126 + 1.127 + info("loading test page: " + testPageURL); 1.128 + content.location = testPageURL; 1.129 +}