forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser_forbidden.js
40 lines (33 loc) · 1.38 KB
/
browser_forbidden.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
/* Ensure that pages in the forbidden list are blocked. */
const PREF_FORBIDDEN_ENABLED = "browser.safebrowsing.forbiddenURIs.enabled";
const BENIGN_PAGE = "http://example.com/";
const FORBIDDEN_PAGE = "http://www.itisatrap.org/firefox/forbidden.html";
var tabbrowser = null;
registerCleanupFunction(function() {
tabbrowser = null;
Services.prefs.clearUserPref(PREF_FORBIDDEN_ENABLED);
while (gBrowser.tabs.length > 1) {
gBrowser.removeCurrentTab();
}
});
function testBenignPage(window) {
info("Non-forbidden content must not be blocked");
var getmeout_button = window.document.getElementById("getMeOutButton");
var ignorewarning_button = window.document.getElementById("ignoreWarningButton");
ok(!getmeout_button, "GetMeOut button not present");
ok(!ignorewarning_button, "IgnoreWarning button not present");
}
function testForbiddenPage(window) {
info("Forbidden content must be blocked");
ok(true, "about:blocked was shown");
}
add_task(function* testNormalBrowsing() {
tabbrowser = gBrowser;
let tab = tabbrowser.selectedTab = tabbrowser.addTab();
info("Load a test page that's not forbidden");
yield promiseTabLoadEvent(tab, BENIGN_PAGE, "load");
testBenignPage(tab.ownerDocument.defaultView);
info("Load a test page that is forbidden");
yield promiseTabLoadEvent(tab, FORBIDDEN_PAGE, "AboutBlockedLoaded");
testForbiddenPage(tab.ownerDocument.defaultView);
});