dom/indexedDB/test/browser_permissionsPromptDeny.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:61068f7be918
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
5
6 const testPageURL = "http://mochi.test:8888/browser/" +
7 "dom/indexedDB/test/browser_permissionsPrompt.html";
8 const notificationID = "indexedDB-permissions-prompt";
9
10 function test()
11 {
12 waitForExplicitFinish();
13 // We want the prompt.
14 PopupNotifications.transitionsEnabled = false;
15 setPermission(testPageURL, "indexedDB", "allow");
16 executeSoon(test1);
17 }
18
19 function test1()
20 {
21 info("creating tab");
22 gBrowser.selectedTab = gBrowser.addTab();
23
24 gBrowser.selectedBrowser.addEventListener("load", function () {
25 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
26
27 setFinishedCallback(function(result, exception) {
28 ok(!result, "No database created");
29 is(exception, "InvalidStateError", "Correct exception");
30 is(getPermission(testPageURL, "indexedDB"),
31 Components.interfaces.nsIPermissionManager.DENY_ACTION,
32 "Correct permission set");
33 gBrowser.removeCurrentTab();
34 executeSoon(test2);
35 });
36
37 registerPopupEventHandler("popupshowing", function () {
38 ok(true, "prompt showing");
39 });
40 registerPopupEventHandler("popupshown", function () {
41 ok(true, "prompt shown");
42 triggerSecondaryCommand(this, 0);
43 });
44 registerPopupEventHandler("popuphidden", function () {
45 ok(true, "prompt hidden");
46 });
47
48 }, true);
49
50 info("loading test page: " + testPageURL);
51 content.location = testPageURL;
52 }
53
54 function test2()
55 {
56 info("creating tab");
57 gBrowser.selectedTab = gBrowser.addTab();
58 gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
59
60 gBrowser.selectedBrowser.addEventListener("load", function () {
61 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
62
63 setFinishedCallback(function(result, exception) {
64 ok(!result, "No database created");
65 is(exception, "InvalidStateError", "Correct exception");
66 is(getPermission(testPageURL, "indexedDB"),
67 Components.interfaces.nsIPermissionManager.DENY_ACTION,
68 "Correct permission set");
69 gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
70 unregisterAllPopupEventHandlers();
71 gBrowser.removeCurrentTab();
72 PopupNotifications.transitionsEnabled = true;
73 executeSoon(test3);
74 });
75
76 registerPopupEventHandler("popupshowing", function () {
77 ok(false, "prompt showing");
78 });
79 registerPopupEventHandler("popupshown", function () {
80 ok(false, "prompt shown");
81 });
82 registerPopupEventHandler("popuphidden", function () {
83 ok(false, "prompt hidden");
84 });
85
86 }, true);
87
88 info("loading test page: " + testPageURL);
89 content.location = testPageURL;
90 }
91
92 function test3()
93 {
94 info("creating tab");
95 gBrowser.selectedTab = gBrowser.addTab();
96
97 gBrowser.selectedBrowser.addEventListener("load", function () {
98 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
99
100 setFinishedCallback(function(result, exception) {
101 ok(!result, "No database created");
102 is(exception, "InvalidStateError", "Correct exception");
103 is(getPermission(testPageURL, "indexedDB"),
104 Components.interfaces.nsIPermissionManager.DENY_ACTION,
105 "Correct permission set");
106 gBrowser.removeCurrentTab();
107 unregisterAllPopupEventHandlers();
108 removePermission(testPageURL, "indexedDB");
109 executeSoon(finish);
110 });
111
112 registerPopupEventHandler("popupshowing", function () {
113 ok(false, "Shouldn't show a popup this time");
114 });
115 registerPopupEventHandler("popupshown", function () {
116 ok(false, "Shouldn't show a popup this time");
117 });
118 registerPopupEventHandler("popuphidden", function () {
119 ok(false, "Shouldn't show a popup this time");
120 });
121
122 }, true);
123
124 info("loading test page: " + testPageURL);
125 content.location = testPageURL;
126 }

mercurial