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 // Make sure this is a unique origin or the tests will randomly fail!
7 const testPageURL = "http://bug704464-1.example.com/browser/" +
8 "dom/indexedDB/test/browser_quotaPrompt.html";
9 const notificationID = "indexedDB-quota-prompt";
11 function test()
12 {
13 waitForExplicitFinish();
14 requestLongerTimeout(10);
15 PopupNotifications.transitionsEnabled = false;
16 removePermission(testPageURL, "indexedDB-unlimited");
17 Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
18 executeSoon(test1);
19 }
21 let addMoreTest1Count = 0;
23 function test1()
24 {
25 gBrowser.selectedTab = gBrowser.addTab();
27 gBrowser.selectedBrowser.addEventListener("load", function () {
28 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
30 let seenPopupCount;
32 setFinishedCallback(function(result) {
33 is(result, "ready", "Got 'ready' result");
35 setFinishedCallback(function(result) {
36 is(result, "complete", "Got 'complete' result");
38 if (addMoreTest1Count > seenPopupCount + 5) {
39 setFinishedCallback(function(result) {
40 is(result, "finished", "Got 'finished' result");
41 is(getPermission(testPageURL, "indexedDB-unlimited"),
42 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
43 "Correct permission set");
44 gBrowser.removeCurrentTab();
45 unregisterAllPopupEventHandlers();
46 executeSoon(finish);
47 });
48 executeSoon(function() { dispatchEvent("indexedDB-done"); });
49 }
50 else {
51 ++addMoreTest1Count;
52 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
53 }
54 });
55 ++addMoreTest1Count;
56 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
57 });
59 registerPopupEventHandler("popupshowing", function () {
60 ok(true, "prompt showing");
61 seenPopupCount = addMoreTest1Count;
62 });
63 registerPopupEventHandler("popupshown", function () {
64 ok(true, "prompt shown");
65 triggerMainCommand(this);
66 });
67 registerPopupEventHandler("popuphidden", function () {
68 ok(true, "prompt hidden");
69 });
71 }, true);
73 info("loading test page: " + testPageURL);
74 content.location = testPageURL + "?v=1";
75 }
77 function test2()
78 {
79 gBrowser.selectedTab = gBrowser.addTab();
81 gBrowser.selectedBrowser.addEventListener("load", function () {
82 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
84 let seenPopup;
85 let addMoreCount = 0;
87 setFinishedCallback(function(result) {
88 is(result, "ready", "Got 'ready' result");
89 is(getPermission(testPageURL, "indexedDB-unlimited"),
90 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
91 "Correct permission set");
93 setFinishedCallback(function(result) {
94 is(result, "complete", "Got 'complete' result");
95 ok(!seenPopup, "No popup");
96 is(getPermission(testPageURL, "indexedDB-unlimited"),
97 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
98 "Correct permission set");
100 if (addMoreCount > addMoreTest1Count + 5) {
101 setFinishedCallback(function(result) {
102 is(result, "finished", "Got 'finished' result");
103 ok(!seenPopup, "No popup");
104 is(getPermission(testPageURL, "indexedDB-unlimited"),
105 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
106 "Correct permission set");
108 gBrowser.removeCurrentTab();
109 unregisterAllPopupEventHandlers();
110 removePermission(testPageURL, "indexedDB");
111 Services.prefs.clearUserPref("dom.indexedDB.warningQuota");
112 PopupNotifications.transitionsEnabled = true;
113 executeSoon(finish);
114 });
115 executeSoon(function() { dispatchEvent("indexedDB-done"); });
116 }
117 else {
118 ++addMoreCount;
119 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
120 }
121 });
122 ++addMoreCount;
123 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
124 });
126 registerPopupEventHandler("popupshowing", function () {
127 ok(false, "Shouldn't show a popup this time");
128 seenPopup = true;
129 });
130 registerPopupEventHandler("popupshown", function () {
131 ok(false, "Shouldn't show a popup this time");
132 });
133 registerPopupEventHandler("popuphidden", function () {
134 ok(false, "Shouldn't show a popup this time");
135 });
137 }, true);
139 info("loading test page: " + testPageURL);
140 content.location = testPageURL + "?v=3";
141 }