dom/indexedDB/test/browser_quotaPromptDelete.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:d68f4e65a9dd
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
5
6 // Make sure this is a unique origin or the tests will randomly fail!
7 const testPageURL = "http://bug702292.example.com/browser/" +
8 "dom/indexedDB/test/browser_quotaPromptDelete.html";
9 const notificationID = "indexedDB-quota-prompt";
10
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 }
20
21 let addMoreTest1Count = 0;
22 let haveReset = false;
23 let secondTimeCount = 0;
24
25 function test1()
26 {
27 gBrowser.selectedTab = gBrowser.addTab();
28
29 gBrowser.selectedBrowser.addEventListener("load", function () {
30 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
31
32 let seenPopupCount;
33
34 setFinishedCallback(function(result) {
35 is(result, "ready", "Got 'ready' result");
36
37 setFinishedCallback(function(result) {
38 if (result == "abort") {
39 setFinishedCallback(function(result) {
40 is(result, "resetDone", "Got 'resetDone' result");
41
42 function secondTimeThroughCallback(result) {
43 is(result, "complete", "Got 'complete' result");
44
45 // If we hit the quota on the Nth iteration last time, we should
46 // be able to go N-1 iterations without hitting it after
47 // obliterating the db.
48 if (++secondTimeCount < addMoreTest1Count - 1) {
49 secondTimeThroughAddMore();
50 } else {
51 setFinishedCallback(function(result) {
52 is(result, "finished", "Got 'finished' result");
53 is(getPermission(testPageURL, "indexedDB-unlimited"),
54 Components.interfaces.nsIPermissionManager.DENY_ACTION,
55 "Correct permission set");
56 gBrowser.removeCurrentTab();
57 unregisterAllPopupEventHandlers();
58 PopupNotifications.transitionsEnabled = true;
59 executeSoon(finish);
60 });
61 executeSoon(function() { dispatchEvent("indexedDB-done"); });
62 }
63 }
64
65 function secondTimeThroughAddMore() {
66 setFinishedCallback(secondTimeThroughCallback);
67 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
68 }
69
70 haveReset = true;
71 secondTimeThroughAddMore();
72 });
73 executeSoon(function() { dispatchEvent("indexedDB-reset"); });
74 }
75 else {
76 ++addMoreTest1Count;
77 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
78 }
79 });
80 ++addMoreTest1Count;
81 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
82 });
83
84 registerPopupEventHandler("popupshowing", function () {
85 ok(true, "prompt showing");
86 seenPopupCount = addMoreTest1Count - 1;
87 });
88 registerPopupEventHandler("popupshown", function () {
89 ok(true, "prompt shown");
90 ok(!haveReset, "Shouldn't get here twice!");
91 triggerSecondaryCommand(this, 0);
92 });
93 registerPopupEventHandler("popuphidden", function () {
94 ok(true, "prompt hidden");
95 });
96
97 }, true);
98
99 info("loading test page: " + testPageURL);
100 content.location = testPageURL;
101 }

mercurial