This commit is contained in:
Dão Gottwald 2009-09-16 12:21:19 +02:00
Родитель 6b918c131c
Коммит 04df8dd1a4
15 изменённых файлов: 162 добавлений и 210 удалений

Просмотреть файл

@ -1,49 +1,42 @@
var listener = {
testFunction : null,
handleEvent : function (e) {
testFunction: null,
handleEvent: function (e) {
this.testFunction();
}
}
var newBrowser;
/* Tests for correct behaviour of getEffectiveHost on identity handler */
function test() {
waitForExplicitFinish();
ok(gIdentityHandler, "gIdentityHandler should exist");
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
newBrowser.addEventListener("load", listener, true);
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", listener, true);
listener.testFunction = testNormalDomain;
newBrowser.contentWindow.location = 'http://test1.example.org/';
content.location = "http://test1.example.org/";
}
function testNormalDomain() {
is(gIdentityHandler._lastLocation.host, 'test1.example.org', "Identity handler is getting the full location");
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for test1.example.org");
listener.testFunction = testNormalDomainWithPort;
newBrowser.contentWindow.location = 'http://sub1.test1.example.org:8000/';
content.location = "http://sub1.test1.example.org:8000/";
}
function testNormalDomainWithPort() {
is(gIdentityHandler._lastLocation.host, 'sub1.test1.example.org:8000', "Identity handler is getting port information");
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for sub1.test1.example.org:8000");
listener.testFunction = testIPWithPort;
newBrowser.contentWindow.location = 'http://127.0.0.1:8888/';
content.location = "http://127.0.0.1:8888/";
}
function testIPWithPort() {
is(gIdentityHandler.getEffectiveHost(), '127.0.0.1', "getEffectiveHost should return 127.0.0.1 for 127.0.0.1:8888");
newBrowser.removeEventListener("load", listener, true);
gBrowser.selectedBrowser.removeEventListener("load", listener, true);
gBrowser.removeCurrentTab();
finish();
}

Просмотреть файл

@ -5,9 +5,6 @@ var invalidPage = 'http://127.0.0.1:55555/';
var validPage = 'http://example.com/';
var testPage = 'data:text/html,<frameset cols="400,400"><frame src="' + validPage + '"><frame src="' + invalidPage + '"></frameset>';
// Keep track of the browser inside our frame
var newBrowser;
// Store the tab and window created in tests 2 and 3 respectively
var test2tab;
var test3window;
@ -16,87 +13,80 @@ var test3window;
var intervalID;
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
newBrowser.addEventListener("load", test1Setup, true);
newBrowser.contentWindow.location = testPage;
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", test1Setup, true);
content.location = testPage;
}
function test1Setup() {
if(newBrowser.contentWindow.frames.length < 2 ||
newBrowser.contentWindow.frames[1].document.location != invalidPage)
if (content.frames.length < 2 ||
content.frames[1].location != invalidPage)
// The error frame hasn't loaded yet
return;
newBrowser.removeEventListener("load", test1Setup, true);
var badFrame = newBrowser.contentWindow.frames[1];
gBrowser.selectedBrowser.removeEventListener("load", test1Setup, true);
var badFrame = content.frames[1];
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
// We'd like to use another load listener here, but error pages don't fire load events
contextMenu.showOnlyThisFrame();
intervalID = window.setInterval(testShowOnlyThisFrame, 3000);
intervalID = setInterval(testShowOnlyThisFrame, 3000);
}
function testShowOnlyThisFrame() {
if(newBrowser.contentDocument.location.href == testPage)
if (content.location.href == testPage)
// This is a stale event from the original page loading
return;
// We should now have loaded the error page frame content directly
// in the tab, make sure the URL is right.
window.clearInterval(intervalID);
is(newBrowser.contentDocument.location.href, invalidPage, "Should navigate to page url, not about:neterror");
clearInterval(intervalID);
is(content.location.href, invalidPage, "Should navigate to page url, not about:neterror");
// Go back to the frames page
gBrowser.addEventListener("load", test2Setup, true);
newBrowser.contentWindow.location = testPage;
content.location = testPage;
}
function test2Setup() {
if(newBrowser.contentWindow.frames.length < 2 ||
newBrowser.contentWindow.frames[1].document.location != invalidPage)
if (content.frames.length < 2 ||
content.frames[1].location != invalidPage)
// The error frame hasn't loaded yet
return;
gBrowser.removeEventListener("load", test2Setup, true);
// Now let's do the whole thing again, but this time for "Open frame in new tab"
newBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
var badFrame = newBrowser.contentWindow.frames[1];
var badFrame = content.frames[1];
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
test2tab = contextMenu.openFrameInTab();
ok(test2tab instanceof XULElement, "openFrameInTab() should return an element (non-null)");
is(test2tab.tagName, "tab", "openFrameInTab() should return a *tab* element");
gBrowser.selectedTab = test2tab;
intervalID = window.setInterval(testOpenFrameInTab, 3000);
intervalID = setInterval(testOpenFrameInTab, 3000);
}
function testOpenFrameInTab() {
if(gBrowser.contentDocument.location.href == "about:blank")
if (gBrowser.contentDocument.location.href == "about:blank")
// Wait another cycle
return;
window.clearInterval(intervalID);
clearInterval(intervalID);
// We should now have the error page in a new, active tab.
is(gBrowser.contentDocument.location.href, invalidPage, "New tab should have page url, not about:neterror");
@ -107,30 +97,28 @@ function testOpenFrameInTab() {
}
function test3Setup() {
// One more time, for "Open frame in new window"
newBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
var badFrame = newBrowser.contentWindow.frames[1];
var badFrame = content.frames[1];
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
test3window = contextMenu.openFrame();
ok(test3window instanceof Window, "openFrame() should return a window (non-null) ");
intervalID = window.setInterval(testOpenFrame, 3000);
intervalID = setInterval(testOpenFrame, 3000);
}
function testOpenFrame() {
if(test3window.content.document.location.href == "about:blank")
if (test3window.content.location.href == "about:blank")
// Wait another cycle
return;
window.clearInterval(intervalID);
is(test3window.content.document.location.href, invalidPage, "New window should have page url, not about:neterror");
clearInterval(intervalID);
is(test3window.content.location.href, invalidPage, "New window should have page url, not about:neterror");
test3window.close();
cleanup();
}

Просмотреть файл

@ -4,12 +4,11 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
let newBrowser = gBrowser.selectedBrowser;
newBrowser.addEventListener("load", function() {
newBrowser.removeEventListener("load", arguments.callee, true);
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
let doc = newBrowser.contentDocument;
let doc = gBrowser.contentDocument;
let testInput = function(type, expected) {
let element = doc.createElement("input");
element.setAttribute("type", type);
@ -50,5 +49,5 @@ function test() {
gBrowser.removeCurrentTab();
finish();
}, true);
newBrowser.loadURI("data:text/html,test");
content.location = "data:text/html,test";
}

Просмотреть файл

@ -46,28 +46,26 @@ let testPage = 'data:text/html,<body><button onblur="this.parentNode.removeChild
function test() {
waitForExplicitFinish();
// Prepare the test tab
let testTab = gBrowser.addTab();
gBrowser.selectedTab = testTab;
let testBrowser = gBrowser.getBrowserForTab(testTab);
gBrowser.selectedTab = gBrowser.addTab();
// Do stuff just after the page loads, so the page script can do its stuff
testBrowser.addEventListener("load", function() setTimeout(function() {
// The test page loaded, so open an empty tab, select it, then restore
// the test tab. This causes the test page's focused element to be removed
// from its document.
let emptyTab = gBrowser.addTab();
gBrowser.selectedTab = emptyTab;
gBrowser.removeCurrentTab();
gBrowser.selectedTab = testTab;
gBrowser.selectedBrowser.addEventListener("load", function () {
setTimeout(function () {
var testPageWin = content;
// Make sure focus is given to the window because the element is now gone
is(document.commandDispatcher.focusedWindow, window.content,
"content window is focused");
gBrowser.removeCurrentTab();
finish();
}, 0), true);
// The test page loaded, so open an empty tab, select it, then restore
// the test tab. This causes the test page's focused element to be removed
// from its document.
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.removeCurrentTab();
// Start the test by loading the test page
testBrowser.contentWindow.location = testPage;
// Make sure focus is given to the window because the element is now gone
is(document.commandDispatcher.focusedWindow, testPageWin,
"content window is focused");
gBrowser.removeCurrentTab();
finish();
}, 0);
}, true);
content.location = testPage;
}

Просмотреть файл

@ -47,7 +47,7 @@ function test() {
ok(bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(minutesSinceMidnight > 10)
if (minutesSinceMidnight > 10)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
@ -58,7 +58,7 @@ function test() {
ok(formhist.nameExists("2hour10minutes"), "2hour10minutes form entry should still exist");
ok(formhist.nameExists("4hour"), "4hour form entry should still exist");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(minutesSinceMidnight > 10)
if (minutesSinceMidnight > 10)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
@ -71,7 +71,7 @@ function test() {
ok(downloadExists(5555553), "<4 hour old download should still be present");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
if(minutesSinceMidnight > 10)
if (minutesSinceMidnight > 10)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 1 hour
@ -85,7 +85,7 @@ function test() {
ok(bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(hoursSinceMidnight > 1)
if (hoursSinceMidnight > 1)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
@ -95,7 +95,7 @@ function test() {
ok(formhist.nameExists("2hour10minutes"), "2hour10minutes form entry should still exist");
ok(formhist.nameExists("4hour"), "4hour form entry should still exist");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(hoursSinceMidnight > 1)
if (hoursSinceMidnight > 1)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
@ -107,7 +107,7 @@ function test() {
ok(downloadExists(5555553), "<4 hour old download should still be present");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
if(hoursSinceMidnight > 1)
if (hoursSinceMidnight > 1)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 1 hour 10 minutes
@ -120,7 +120,7 @@ function test() {
ok(bhist.isVisited(makeURI("http://2hour10minutes.com/")), "Pretend visit to 2hour10minutes.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(minutesSinceMidnight > 70)
if (minutesSinceMidnight > 70)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
@ -129,7 +129,7 @@ function test() {
ok(formhist.nameExists("2hour10minutes"), "2hour10minutes form entry should still exist");
ok(formhist.nameExists("4hour"), "4hour form entry should still exist");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(minutesSinceMidnight > 70)
if (minutesSinceMidnight > 70)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
@ -139,7 +139,7 @@ function test() {
ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
ok(downloadExists(5555553), "<4 hour old download should still be present");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
if(minutesSinceMidnight > 70)
if (minutesSinceMidnight > 70)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 2 hours
@ -150,7 +150,7 @@ function test() {
ok(bhist.isVisited(makeURI("http://2hour10minutes.com/")), "Pretend visit to 2hour10minutes.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(hoursSinceMidnight > 2)
if (hoursSinceMidnight > 2)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
@ -158,7 +158,7 @@ function test() {
ok(formhist.nameExists("2hour10minutes"), "2hour10minutes form entry should still exist");
ok(formhist.nameExists("4hour"), "4hour form entry should still exist");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(hoursSinceMidnight > 2)
if (hoursSinceMidnight > 2)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
@ -168,7 +168,7 @@ function test() {
ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
ok(downloadExists(5555553), "<4 hour old download should still be present");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
if(hoursSinceMidnight > 2)
if (hoursSinceMidnight > 2)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 2 hours 10 minutes
@ -179,14 +179,14 @@ function test() {
ok(!bhist.isVisited(makeURI("http://2hour10minutes.com")), "Pretend visit to 2hour10minutes.com should now be deleted");
ok(bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should still exist");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(minutesSinceMidnight > 130)
if (minutesSinceMidnight > 130)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
ok(!formhist.nameExists("2hour10minutes"), "2hour10minutes form entry should be deleted");
ok(formhist.nameExists("4hour"), "4hour form entry should still exist");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(minutesSinceMidnight > 130)
if (minutesSinceMidnight > 130)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
@ -194,7 +194,7 @@ function test() {
ok(downloadExists(5555553), "<4 hour old download should still be present");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
ok(downloadExists(5555550), "Year old download should still be present");
if(minutesSinceMidnight > 130)
if (minutesSinceMidnight > 130)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 4 hours
@ -203,20 +203,20 @@ function test() {
ok(!bhist.isVisited(makeURI("http://4hour.com")), "Pretend visit to 4hour.com should now be deleted");
ok(bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should still exist");
if(hoursSinceMidnight > 4)
if (hoursSinceMidnight > 4)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
ok(!formhist.nameExists("4hour"), "4hour form entry should be deleted");
ok(formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should still exist");
if(hoursSinceMidnight > 4)
if (hoursSinceMidnight > 4)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
ok(!downloadExists(5555553), "<4 hour old download should now be deleted");
ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
ok(downloadExists(5555550), "Year old download should still be present");
if(hoursSinceMidnight > 4)
if (hoursSinceMidnight > 4)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear 4 hours 10 minutes
@ -225,18 +225,18 @@ function test() {
s.range = null;
ok(!bhist.isVisited(makeURI("http://4hour10minutes.com/")), "Pretend visit to 4hour10minutes.com should now be deleted");
if(minutesSinceMidnight > 250)
if (minutesSinceMidnight > 250)
ok(bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should still exist");
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
ok(!formhist.nameExists("4hour10minutes"), "4hour10minutes form entry should be deleted");
if(minutesSinceMidnight > 250)
if (minutesSinceMidnight > 250)
ok(formhist.nameExists("today"), "today form entry should still exist");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
ok(!downloadExists(5555558), "4 hour 10 minute download should now be deleted");
ok(downloadExists(5555550), "Year old download should still be present");
if(minutesSinceMidnight > 250)
if (minutesSinceMidnight > 250)
ok(downloadExists(5555554), "'Today' download should still be present");
// Clear Today

Просмотреть файл

@ -55,7 +55,7 @@ function test() {
"focusedElement after tab change, focus in url field, no focus in new tab");
// focusing a button in the current tab should focus it
var button1 = browser1.contentWindow.document.getElementById("button1");
var button1 = browser1.contentDocument.getElementById("button1");
expectFocusShift(function () button1.focus(),
browser1.contentWindow, button1, true,
"focusedWindow after focus in focused tab");
@ -63,7 +63,7 @@ function test() {
// focusing a button in a background tab should not change the actual
// focus, but should set the focus that would be in that background tab to
// that button.
var button2 = browser2.contentWindow.document.getElementById("button2");
var button2 = browser2.contentDocument.getElementById("button2");
button2.focus();
expectFocusShift(function () button2.focus(),

Просмотреть файл

@ -1,45 +1,40 @@
var newBrowser
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to a site with a broken cert
window.addEventListener("DOMContentLoaded", testBrokenCert, true);
newBrowser.contentWindow.location = 'https://nocert.example.com/';
content.location = "https://nocert.example.com/";
}
function testBrokenCert() {
window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
// Confirm that we are displaying the contributed error page, not the default
ok(/^about:certerror/.test(gBrowser.contentWindow.document.documentURI), "Broken page should go to about:certerror, not about:neterror");
ok(/^about:certerror/.test(gBrowser.contentDocument.documentURI), "Broken page should go to about:certerror, not about:neterror");
// Confirm that the expert section is collapsed
var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
var expertDiv = gBrowser.contentDocument.getElementById("expertContent");
ok(expertDiv, "Expert content div should exist");
ok(expertDiv.hasAttribute("collapsed"), "Expert content should be collapsed by default");
// Tweak the expert mode pref
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch)
.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
gPrefService.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
window.addEventListener("DOMContentLoaded", testExpertPref, true);
newBrowser.reload();
gBrowser.reload();
}
function testExpertPref() {
window.removeEventListener("DOMContentLoaded", testExpertPref, true);
var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
var technicalDiv = gBrowser.contentWindow.document.getElementById("technicalContent");
var expertDiv = gBrowser.contentDocument.getElementById("expertContent");
var technicalDiv = gBrowser.contentDocument.getElementById("technicalContent");
ok(!expertDiv.hasAttribute("collapsed"), "Expert content should not be collapsed with the expert mode pref set");
ok(!technicalDiv.hasAttribute("collapsed"), "Technical content should not be collapsed with the expert mode pref set");
// Clean up
gBrowser.removeCurrentTab();
gPrefService.clearUserPref("browser.xul.error_pages.expert_bad_cert");
finish();
}

Просмотреть файл

@ -47,50 +47,46 @@ function test() {
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt_page.html";
waitForExplicitFinish();
let pageTab = gBrowser.addTab();
gBrowser.selectedTab = pageTab;
let pageBrowser = gBrowser.getBrowserForTab(pageTab);
pageBrowser.addEventListener("load", function () {
pageBrowser.removeEventListener("load", arguments.callee, true);
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setTimeout(function() {
// Make sure the notification is correctly displayed with a remember control
let notificationBox = gBrowser.getNotificationBox(pageBrowser);
let notificationBox = gBrowser.getNotificationBox();
let notification = notificationBox.getNotificationWithValue("geolocation");
ok(notification, "Notification box should be displaying outside of private browsing mode");
is(notification.getElementsByClassName("rememberChoice").length, 1,
"The remember control must be displayed outside of private browsing mode");
notificationBox.currentNotification.close();
gBrowser.removeTab(pageTab);
gBrowser.removeCurrentTab();
// enter the private browsing mode
pb.privateBrowsingEnabled = true;
pageTab = gBrowser.addTab();
gBrowser.selectedTab = pageTab;
pageBrowser = gBrowser.getBrowserForTab(pageTab);
pageBrowser.addEventListener("load", function () {
pageBrowser.removeEventListener("load", arguments.callee, true);
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setTimeout(function() {
setTimeout(function () {
// Make sure the notification is correctly displayed without a remember control
let notificationBox = gBrowser.getNotificationBox(pageBrowser);
let notificationBox = gBrowser.getNotificationBox();
let notification = notificationBox.getNotificationWithValue("geolocation");
ok(notification, "Notification box should be displaying outside of private browsing mode");
is(notification.getElementsByClassName("rememberChoice").length, 0,
"The remember control must not be displayed inside of private browsing mode");
notificationBox.currentNotification.close();
gBrowser.removeTab(pageTab);
gBrowser.removeCurrentTab();
// cleanup
pb.privateBrowsingEnabled = false;
finish();
}, 100); // remember control is added in a setTimeout(0) call
}, true);
pageBrowser.contentWindow.location = testPageURL;
content.location = testPageURL;
}, 100); // remember control is added in a setTimeout(0) call
}, true);
pageBrowser.contentWindow.location = testPageURL;
content.location = testPageURL;
}

Просмотреть файл

@ -55,7 +55,7 @@ function test() {
dialog.addEventListener("load", function () {
dialog.removeEventListener("load", arguments.callee, false);
let browser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
let browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);

Просмотреть файл

@ -40,18 +40,15 @@
function test() {
// initialization
let prefBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
const kTestURL = "https://example.com/";
const TEST_URL = "https://example.com/";
// load an SSL site in the first tab and wait for it to finish loading
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
@ -62,19 +59,19 @@ function test() {
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
is(browser.contentWindow.location, kTestURL,
is(content.location, TEST_URL,
"The original SSL page should be loaded at this stage");
gBrowser.removeTab(tab);
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
gBrowser.removeCurrentTab();
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}, true);
executeSoon(function(){
browser.contentWindow.location = kTestURL;
executeSoon(function () {
content.location = TEST_URL;
});
}, true);
browser.contentWindow.location = kTestURL;
content.location = TEST_URL;
waitForExplicitFinish();
}

Просмотреть файл

@ -42,10 +42,9 @@ function test() {
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
const kTestURL = "data:text/plain,test";
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
const TEST_URL = "data:text/plain,test";
gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
@ -58,8 +57,7 @@ function test() {
// enter private browsing mode
pb.privateBrowsingEnabled = true;
tab = gBrowser.selectedTab;
browser = gBrowser.getBrowserForTab(tab);
browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
// setTimeout is needed here because the onload handler of about:privatebrowsing sets the focus
setTimeout(function() {
@ -71,8 +69,7 @@ function test() {
// leave private browsing mode
pb.privateBrowsingEnabled = false;
tab = gBrowser.selectedTab;
browser = gBrowser.getBrowserForTab(tab);
browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
// ensure that the URL bar is no longer focused after leaving the private browsing mode
isnot(document.commandDispatcher.focusedElement, gURLBar.inputField,
@ -80,13 +77,13 @@ function test() {
// ensure that the URL bar is no longer empty after leaving the private browsing mode
isnot(gURLBar.value, "", "URL Bar should no longer be empty after leaving the private browsing mode");
gBrowser.removeTab(tab);
gBrowser.removeCurrentTab();
finish();
}, true);
}, 0);
}, true);
}, true);
browser.contentWindow.location = kTestURL;
content.location = TEST_URL;
waitForExplicitFinish();
}

Просмотреть файл

@ -40,9 +40,7 @@
function test() {
// initialization
let prefBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
@ -80,9 +78,8 @@ function test() {
function testTabTitle(url, insidePB, expected_title, funcNext) {
pb.privateBrowsingEnabled = insidePB;
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
let tab = gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
@ -117,7 +114,7 @@ function test() {
function cleanup() {
pb.privateBrowsingEnabled = false;
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
finish();
}

Просмотреть файл

@ -1,41 +1,38 @@
/* Check for the intended visibility of the "Ignore this warning" text*/
var newBrowser
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to malware site. Can't use an onload listener here since
// error pages don't fire onload
window.addEventListener("DOMContentLoaded", testMalware, true);
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-an-attack.html';
content.location = "http://www.mozilla.com/firefox/its-an-attack.html";
}
function testMalware() {
window.removeEventListener("DOMContentLoaded", testMalware, true);
// Confirm that "Ignore this warning" is visible - bug 422410
var el = newBrowser.contentDocument.getElementById("ignoreWarningButton");
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for malware");
var style = newBrowser.contentWindow.getComputedStyle(el, null);
var style = content.getComputedStyle(el, null);
is(style.display, "-moz-box", "Ignore Warning button should be display:-moz-box for malware");
// Now launch the phishing test
window.addEventListener("DOMContentLoaded", testPhishing, true);
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-a-trap.html';
content.location = "http://www.mozilla.com/firefox/its-a-trap.html";
}
function testPhishing() {
window.removeEventListener("DOMContentLoaded", testPhishing, true);
var el = newBrowser.contentDocument.getElementById("ignoreWarningButton");
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for phishing");
var style = newBrowser.contentWindow.getComputedStyle(el, null);
var style = content.getComputedStyle(el, null);
is(style.display, "-moz-box", "Ignore Warning button should be display:-moz-box for phishing");
gBrowser.removeCurrentTab();

Просмотреть файл

@ -3,20 +3,16 @@ menu items.
Mac makes this astonishingly painful to test since their help menu is special magic,
but we can at least test it on the other platforms.*/
var newBrowser;
var menu;
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to a normal site
gBrowser.addEventListener("load", testNormal, false);
newBrowser.contentWindow.location = 'http://example.com/';
content.location = "http://example.com/";
}
function testNormal() {
@ -41,7 +37,7 @@ function testNormal_PopupListener() {
// Now launch the phishing test. Can't use onload here because error pages don't
// fire normal load events.
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-a-trap.html';
content.location = "http://www.mozilla.com/firefox/its-a-trap.html";
window.setTimeout(testPhishing, 2000);
}

Просмотреть файл

@ -52,8 +52,7 @@ function test() {
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let browser = tabbrowser.getBrowserForTab(tab);
let history = browser.webNavigation.sessionHistory;
let history = tab.linkedBrowser.webNavigation.sessionHistory;
ok(history.count >= 1, "the new tab does have at least one history entry");
ss.setTabState(tab, "{ entries: [] }");