forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
browser_quotaPromptDeny.js
148 lines (126 loc) · 4.79 KB
/
browser_quotaPromptDeny.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Make sure this is a unique origin or the tests will randomly fail!
const testPageURL = "http://bug704464-2.example.com/browser/" +
"dom/indexedDB/test/browser_quotaPrompt.html";
const notificationID = "indexedDB-quota-prompt";
function test()
{
waitForExplicitFinish();
requestLongerTimeout(10);
removePermission(testPageURL, "indexedDB-unlimited");
Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
executeSoon(test1);
}
let addMoreTest1Count = 0;
function test1()
{
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
let seenPopupCount;
setFinishedCallback(function(result) {
is(result, "ready", "Got 'ready' result");
setFinishedCallback(function(result) {
if (!seenPopupCount) {
is(result, "complete", "Got 'complete' result");
}
else {
is(result, "abort QuotaExceededError", "Got 'abort' result");
}
if (addMoreTest1Count >= seenPopupCount + 5) {
setFinishedCallback(function(result) {
is(result, "finished", "Got 'finished' result");
is(getPermission(testPageURL, "indexedDB-unlimited"),
Components.interfaces.nsIPermissionManager.DENY_ACTION,
"Correct permission set");
gBrowser.removeCurrentTab();
unregisterAllPopupEventHandlers();
addMoreTest1Count = seenPopupCount;
executeSoon(test2);
});
executeSoon(function() { dispatchEvent("indexedDB-done"); });
}
else {
++addMoreTest1Count;
executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
}
});
++addMoreTest1Count;
executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
});
registerPopupEventHandler("popupshowing", function () {
ok(true, "prompt showing");
seenPopupCount = addMoreTest1Count - 1;
});
registerPopupEventHandler("popupshown", function () {
ok(true, "prompt shown");
triggerSecondaryCommand(this, 0);
});
registerPopupEventHandler("popuphidden", function () {
ok(true, "prompt hidden");
});
}, true);
info("loading test page: " + testPageURL);
content.location = testPageURL + "?v=5";
}
function test2()
{
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
let seenPopup;
let addMoreCount = 0;
let lastResult;
setFinishedCallback(function(result) {
is(result, "ready", "Got 'ready' result");
is(getPermission(testPageURL, "indexedDB-unlimited"),
Components.interfaces.nsIPermissionManager.DENY_ACTION,
"Correct permission set");
setFinishedCallback(function(result) {
info("Got '" + result + "' result");
lastResult = result;
ok(!seenPopup, "No popup");
is(getPermission(testPageURL, "indexedDB-unlimited"),
Components.interfaces.nsIPermissionManager.DENY_ACTION,
"Correct permission set");
if (addMoreCount > addMoreTest1Count + 5) {
setFinishedCallback(function(result) {
is(result, "finished", "Got 'finished' result");
is(lastResult, "abort QuotaExceededError", "Aborted as expected");
ok(!seenPopup, "No popup");
is(getPermission(testPageURL, "indexedDB-unlimited"),
Components.interfaces.nsIPermissionManager.DENY_ACTION,
"Correct permission set");
gBrowser.removeCurrentTab();
unregisterAllPopupEventHandlers();
removePermission(testPageURL, "indexedDB");
Services.prefs.clearUserPref("dom.indexedDB.warningQuota");
executeSoon(finish);
});
executeSoon(function() { dispatchEvent("indexedDB-done"); });
}
else {
++addMoreCount;
executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
}
});
++addMoreCount;
executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
});
registerPopupEventHandler("popupshowing", function () {
ok(false, "Shouldn't show a popup this time");
seenPopup = true;
});
registerPopupEventHandler("popupshown", function () {
ok(false, "Shouldn't show a popup this time");
});
registerPopupEventHandler("popuphidden", function () {
ok(false, "Shouldn't show a popup this time");
});
}, true);
info("loading test page: " + testPageURL);
content.location = testPageURL + "?v=7";
}