|
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 |
|
14 PopupNotifications.transitionsEnabled = false; |
|
15 |
|
16 // We want a prompt. |
|
17 setPermission(testPageURL, "indexedDB", "allow"); |
|
18 executeSoon(test1); |
|
19 } |
|
20 |
|
21 function test1() |
|
22 { |
|
23 info("creating tab"); |
|
24 gBrowser.selectedTab = gBrowser.addTab(); |
|
25 |
|
26 gBrowser.selectedBrowser.addEventListener("load", function () { |
|
27 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
28 |
|
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 }); |
|
39 |
|
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 }); |
|
50 |
|
51 }, true); |
|
52 |
|
53 info("loading test page: " + testPageURL); |
|
54 content.location = testPageURL; |
|
55 } |
|
56 |
|
57 function test2() |
|
58 { |
|
59 info("creating tab"); |
|
60 gBrowser.selectedTab = gBrowser.addTab(); |
|
61 |
|
62 gBrowser.selectedBrowser.addEventListener("load", function () { |
|
63 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
64 |
|
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 }); |
|
78 |
|
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 }); |
|
88 |
|
89 }, true); |
|
90 |
|
91 info("loading test page: " + testPageURL); |
|
92 content.location = testPageURL; |
|
93 } |