Wed, 31 Dec 2014 06:55:50 +0100
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();
13 // We want the prompt.
14 PopupNotifications.transitionsEnabled = false;
15 setPermission(testPageURL, "indexedDB", "allow");
16 executeSoon(test1);
17 }
19 function test1()
20 {
21 info("creating tab");
22 gBrowser.selectedTab = gBrowser.addTab();
24 gBrowser.selectedBrowser.addEventListener("load", function () {
25 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
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 });
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 });
48 }, true);
50 info("loading test page: " + testPageURL);
51 content.location = testPageURL;
52 }
54 function test2()
55 {
56 info("creating tab");
57 gBrowser.selectedTab = gBrowser.addTab();
58 gBrowser.selectedBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
60 gBrowser.selectedBrowser.addEventListener("load", function () {
61 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
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 });
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 });
86 }, true);
88 info("loading test page: " + testPageURL);
89 content.location = testPageURL;
90 }
92 function test3()
93 {
94 info("creating tab");
95 gBrowser.selectedTab = gBrowser.addTab();
97 gBrowser.selectedBrowser.addEventListener("load", function () {
98 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
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 });
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 });
122 }, true);
124 info("loading test page: " + testPageURL);
125 content.location = testPageURL;
126 }