зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1178163 - Convert browser_bug590206.js to add_task format;r=ttaubert
--HG-- extra : commitid : 5eDsAagG9Ws
This commit is contained in:
Родитель
ae1b982256
Коммит
61bd1320d3
|
@ -1,184 +1,140 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/*
|
||||
* Test the identity mode UI for a variety of page types
|
||||
*/
|
||||
|
||||
const DUMMY = "browser/browser/base/content/test/general/dummy_page.html";
|
||||
|
||||
function loadNewTab(aURL, aCallback) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, aURL).then(aCallback);
|
||||
function loadNewTab(url) {
|
||||
return BrowserTestUtils.openNewForegroundTab(gBrowser, url);
|
||||
}
|
||||
|
||||
function getIdentityMode() {
|
||||
return document.getElementById("identity-box").className;
|
||||
}
|
||||
|
||||
var TESTS = [
|
||||
function test_webpage() {
|
||||
// This test is slow on Linux debug e10s
|
||||
requestLongerTimeout(2);
|
||||
|
||||
add_task(function* test_webpage() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
|
||||
loadNewTab("http://example.com/" + DUMMY, function(aNewTab) {
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
let newTab = yield loadNewTab("http://example.com/" + DUMMY);
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_blank() {
|
||||
add_task(function* test_blank() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
|
||||
loadNewTab("about:blank", function(aNewTab) {
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
let newTab = yield loadNewTab("about:blank");
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_chrome() {
|
||||
add_task(function* test_chrome() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
|
||||
loadNewTab("chrome://mozapps/content/extensions/extensions.xul", function(aNewTab) {
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
let newTab = yield loadNewTab("chrome://mozapps/content/extensions/extensions.xul");
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_https() {
|
||||
add_task(function* test_https() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
|
||||
loadNewTab("https://example.com/" + DUMMY, function(aNewTab) {
|
||||
is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
|
||||
let newTab = yield loadNewTab("https://example.com/" + DUMMY);
|
||||
is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_addons() {
|
||||
add_task(function* test_addons() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
|
||||
loadNewTab("about:addons", function(aNewTab) {
|
||||
is(getIdentityMode(), "chromeUI", "Identity should be chrome");
|
||||
let newTab = yield loadNewTab("about:addons");
|
||||
is(getIdentityMode(), "chromeUI", "Identity should be chrome");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "chromeUI", "Identity should be chrome");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "chromeUI", "Identity should be chrome");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_file() {
|
||||
add_task(function* test_file() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
let fileURI = getTestFilePath("");
|
||||
|
||||
loadNewTab(fileURI, function(aNewTab) {
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
let newTab = yield loadNewTab(fileURI);
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be file");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_resource_uri() {
|
||||
add_task(function test_resource_uri() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
let dataURI = "resource://gre/modules/Services.jsm"
|
||||
|
||||
loadNewTab(dataURI, function(aNewTab) {
|
||||
is(getIdentityMode(), "fileURI", "Identity should be unknown");
|
||||
let newTab = yield loadNewTab(dataURI);
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
is(getIdentityMode(), "fileURI", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "fileURI", "Identity should be unknown");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
||||
function test_data_uri() {
|
||||
add_task(function test_data_uri() {
|
||||
let oldTab = gBrowser.selectedTab;
|
||||
let dataURI = "data:text/html,hi"
|
||||
|
||||
loadNewTab(dataURI, function(aNewTab) {
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
let newTab = yield loadNewTab(dataURI);
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = oldTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.selectedTab = aNewTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
gBrowser.selectedTab = newTab;
|
||||
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
|
||||
|
||||
gBrowser.removeTab(aNewTab);
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
];
|
||||
|
||||
var gTestStart = null;
|
||||
|
||||
function runNextTest() {
|
||||
if (gTestStart)
|
||||
info("Test part took " + (Date.now() - gTestStart) + "ms");
|
||||
|
||||
if (TESTS.length == 0) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
info("Running " + TESTS[0].name);
|
||||
gTestStart = Date.now();
|
||||
TESTS.shift()();
|
||||
};
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
gBrowser.removeTab(newTab);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче