зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376892 - Move browser_about* tests from 'general' to 'about' folder. r=jaws
MozReview-Commit-ID: IGXp9fV9DsR --HG-- rename : browser/base/content/test/general/aboutHome_content_script.js => browser/base/content/test/about/aboutHome_content_script.js rename : browser/base/content/test/general/browser_aboutCertError.js => browser/base/content/test/about/browser_aboutCertError.js rename : browser/base/content/test/general/browser_aboutHealthReport.js => browser/base/content/test/about/browser_aboutHealthReport.js rename : browser/base/content/test/general/browser_aboutHome.js => browser/base/content/test/about/browser_aboutHome.js rename : browser/base/content/test/general/browser_aboutHome_wrapsCorrectly.js => browser/base/content/test/about/browser_aboutHome_wrapsCorrectly.js rename : browser/base/content/test/general/browser_aboutNetError.js => browser/base/content/test/about/browser_aboutNetError.js rename : browser/base/content/test/general/browser_aboutSupport.js => browser/base/content/test/about/browser_aboutSupport.js rename : browser/base/content/test/general/browser_aboutSupport_newtab_security_state.js => browser/base/content/test/about/browser_aboutSupport_newtab_security_state.js rename : browser/base/content/test/general/healthreport_pingData.js => browser/base/content/test/about/healthreport_pingData.js rename : browser/base/content/test/general/healthreport_testRemoteCommands.html => browser/base/content/test/about/healthreport_testRemoteCommands.html rename : browser/base/content/test/general/test_bug959531.html => browser/base/content/test/about/test_bug959531.html
This commit is contained in:
Родитель
88fa774391
Коммит
75d1574406
|
@ -0,0 +1,6 @@
|
|||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>POST Search</ShortName>
|
||||
<Url type="text/html" method="POST" template="http://mochi.test:8888/browser/browser/base/content/test/about/print_postdata.sjs">
|
||||
<Param name="searchterms" value="{searchTerms}"/>
|
||||
</Url>
|
||||
</OpenSearchDescription>
|
|
@ -1 +1,21 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
aboutHome_content_script.js
|
||||
head.js
|
||||
healthreport_pingData.js
|
||||
healthreport_testRemoteCommands.html
|
||||
print_postdata.sjs
|
||||
searchSuggestionEngine.sjs
|
||||
searchSuggestionEngine.xml
|
||||
test_bug959531.html
|
||||
POSTSearchEngine.xml
|
||||
|
||||
[browser_aboutCertError.js]
|
||||
[browser_aboutStopReload.js]
|
||||
[browser_aboutNetError.js]
|
||||
[browser_aboutSupport.js]
|
||||
[browser_aboutSupport_newtab_security_state.js]
|
||||
[browser_aboutHealthReport.js]
|
||||
skip-if = os == "linux" # Bug 924307
|
||||
[browser_aboutHome.js]
|
||||
[browser_aboutHome_wrapsCorrectly.js]
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
|
||||
|
||||
const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/general/";
|
||||
const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/general/";
|
||||
const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/about/";
|
||||
const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/about/";
|
||||
|
||||
const TELEMETRY_LOG_PREF = "toolkit.telemetry.log.level";
|
||||
const telemetryOriginalLogPref = Preferences.get(TELEMETRY_LOG_PREF, null);
|
|
@ -12,7 +12,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
|
|||
"resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const TEST_CONTENT_HELPER = "chrome://mochitests/content/browser/browser/base/" +
|
||||
"content/test/general/aboutHome_content_script.js";
|
||||
"content/test/about/aboutHome_content_script.js";
|
||||
var gRightsVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
|
@ -269,7 +269,7 @@ add_task(async function() {
|
|||
resolve();
|
||||
};
|
||||
Services.obs.addObserver(searchObserver, "browser-search-engine-modified");
|
||||
Services.search.addEngine("http://test:80/browser/browser/base/content/test/general/POSTSearchEngine.xml",
|
||||
Services.search.addEngine("http://test:80/browser/browser/base/content/test/about/POSTSearchEngine.xml",
|
||||
null, null, false);
|
||||
});
|
||||
});
|
||||
|
@ -280,7 +280,7 @@ add_task(async function() {
|
|||
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, async function(browser) {
|
||||
let promise = BrowserTestUtils.browserLoaded(browser);
|
||||
browser.loadURI("https://example.com/browser/browser/base/content/test/general/test_bug959531.html");
|
||||
browser.loadURI("https://example.com/browser/browser/base/content/test/about/test_bug959531.html");
|
||||
await promise;
|
||||
|
||||
await ContentTask.spawn(browser, null, async function() {
|
|
@ -0,0 +1,155 @@
|
|||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg, retryTimes) {
|
||||
retryTimes = typeof retryTimes !== "undefined" ? retryTimes : 30;
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= retryTimes) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
var conditionPassed;
|
||||
try {
|
||||
conditionPassed = condition();
|
||||
} catch (e) {
|
||||
ok(false, e + "\n" + e.stack);
|
||||
conditionPassed = false;
|
||||
}
|
||||
if (conditionPassed) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
||||
|
||||
function promiseWaitForCondition(aConditionFn) {
|
||||
return new Promise(resolve => {
|
||||
waitForCondition(aConditionFn, resolve, "Condition didn't pass.");
|
||||
});
|
||||
}
|
||||
|
||||
function whenTabLoaded(aTab, aCallback) {
|
||||
promiseTabLoadEvent(aTab).then(aCallback);
|
||||
}
|
||||
|
||||
function promiseTabLoaded(aTab) {
|
||||
return new Promise(resolve => {
|
||||
whenTabLoaded(aTab, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a load (or custom) event to finish in a given tab. If provided
|
||||
* load an uri into the tab.
|
||||
*
|
||||
* @param tab
|
||||
* The tab to load into.
|
||||
* @param [optional] url
|
||||
* The url to load, or the current url.
|
||||
* @return {Promise} resolved when the event is handled.
|
||||
* @resolves to the received event
|
||||
* @rejects if a valid load event is not received within a meaningful interval
|
||||
*/
|
||||
function promiseTabLoadEvent(tab, url) {
|
||||
info("Wait tab event: load");
|
||||
|
||||
function handle(loadedUrl) {
|
||||
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
|
||||
info(`Skipping spurious load event for ${loadedUrl}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
info("Tab event received: load");
|
||||
return true;
|
||||
}
|
||||
|
||||
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
|
||||
|
||||
if (url)
|
||||
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the next top-level document load in the current browser. The URI
|
||||
* of the document is compared against aExpectedURL. The load is then stopped
|
||||
* before it actually starts.
|
||||
*
|
||||
* @param aExpectedURL
|
||||
* The URL of the document that is expected to load.
|
||||
* @param aStopFromProgressListener
|
||||
* Whether to cancel the load directly from the progress listener. Defaults to true.
|
||||
* If you're using this method to avoid hitting the network, you want the default (true).
|
||||
* However, the browser UI will behave differently for loads stopped directly from
|
||||
* the progress listener (effectively in the middle of a call to loadURI) and so there
|
||||
* are cases where you may want to avoid stopping the load directly from within the
|
||||
* progress listener callback.
|
||||
* @return promise
|
||||
*/
|
||||
function waitForDocLoadAndStopIt(aExpectedURL, aBrowser = gBrowser.selectedBrowser, aStopFromProgressListener = true) {
|
||||
function content_script(contentStopFromProgressListener) {
|
||||
let { interfaces: Ci, utils: Cu } = Components;
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
let wp = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
|
||||
function stopContent(now, uri) {
|
||||
if (now) {
|
||||
/* Hammer time. */
|
||||
content.stop();
|
||||
|
||||
/* Let the parent know we're done. */
|
||||
sendAsyncMessage("Test:WaitForDocLoadAndStopIt", { uri });
|
||||
} else {
|
||||
setTimeout(stopContent.bind(null, true, uri), 0);
|
||||
}
|
||||
}
|
||||
|
||||
let progressListener = {
|
||||
onStateChange(webProgress, req, flags, status) {
|
||||
dump("waitForDocLoadAndStopIt: onStateChange " + flags.toString(16) + ": " + req.name + "\n");
|
||||
|
||||
if (webProgress.isTopLevel &&
|
||||
flags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
wp.removeProgressListener(progressListener);
|
||||
|
||||
let chan = req.QueryInterface(Ci.nsIChannel);
|
||||
dump(`waitForDocLoadAndStopIt: Document start: ${chan.URI.spec}\n`);
|
||||
|
||||
stopContent(contentStopFromProgressListener, chan.originalURI.spec);
|
||||
}
|
||||
},
|
||||
QueryInterface: XPCOMUtils.generateQI(["nsISupportsWeakReference"])
|
||||
};
|
||||
wp.addProgressListener(progressListener, wp.NOTIFY_STATE_WINDOW);
|
||||
|
||||
/**
|
||||
* As |this| is undefined and we can't extend |docShell|, adding an unload
|
||||
* event handler is the easiest way to ensure the weakly referenced
|
||||
* progress listener is kept alive as long as necessary.
|
||||
*/
|
||||
addEventListener("unload", function() {
|
||||
try {
|
||||
wp.removeProgressListener(progressListener);
|
||||
} catch (e) { /* Will most likely fail. */ }
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
function complete({ data }) {
|
||||
is(data.uri, aExpectedURL, "waitForDocLoadAndStopIt: The expected URL was loaded");
|
||||
mm.removeMessageListener("Test:WaitForDocLoadAndStopIt", complete);
|
||||
resolve();
|
||||
}
|
||||
|
||||
let mm = aBrowser.messageManager;
|
||||
mm.loadFrameScript("data:,(" + content_script.toString() + ")(" + aStopFromProgressListener + ");", true);
|
||||
mm.addMessageListener("Test:WaitForDocLoadAndStopIt", complete);
|
||||
info("waitForDocLoadAndStopIt: Waiting for URL: " + aExpectedURL);
|
||||
});
|
||||
}
|
||||
|
||||
function promiseDisableOnboardingTours() {
|
||||
return SpecialPowers.pushPrefEnv({set: [["browser.onboarding.enabled", false]]});
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
const CC = Components.Constructor;
|
||||
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream",
|
||||
"setInputStream");
|
||||
|
||||
function handleRequest(request, response) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
if (request.method == "GET") {
|
||||
response.write(request.queryString);
|
||||
} else {
|
||||
var body = new BinaryInputStream(request.bodyInputStream);
|
||||
|
||||
var avail;
|
||||
var bytes = [];
|
||||
|
||||
while ((avail = body.available()) > 0)
|
||||
Array.prototype.push.apply(bytes, body.readByteArray(avail));
|
||||
|
||||
var data = String.fromCharCode.apply(null, bytes);
|
||||
response.bodyOutputStream.write(data, data.length);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function handleRequest(req, resp) {
|
||||
let suffixes = ["foo", "bar"];
|
||||
let data = [req.queryString, suffixes.map(s => req.queryString + s)];
|
||||
resp.setHeader("Content-Type", "application/json", false);
|
||||
resp.write(JSON.stringify(data));
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>browser_searchSuggestionEngine searchSuggestionEngine.xml</ShortName>
|
||||
<Url type="application/x-suggestions+json" method="GET" template="http://mochi.test:8888/browser/browser/base/content/test/about/searchSuggestionEngine.sjs?{searchTerms}"/>
|
||||
<Url type="text/html" method="GET" template="http://mochi.test:8888/" rel="searchform"/>
|
||||
</SearchPlugin>
|
|
@ -11,7 +11,6 @@ support-files =
|
|||
alltabslistener.html
|
||||
app_bug575561.html
|
||||
app_subframe_bug575561.html
|
||||
aboutHome_content_script.js
|
||||
audio.ogg
|
||||
browser_bug479408_sample.html
|
||||
browser_bug678392-1.html
|
||||
|
@ -49,8 +48,6 @@ support-files =
|
|||
file_fullscreen-window-open.html
|
||||
file_with_link_to_http.html
|
||||
head.js
|
||||
healthreport_pingData.js
|
||||
healthreport_testRemoteCommands.html
|
||||
moz.png
|
||||
navigating_window_with_download.html
|
||||
offlineQuotaNotification.cacheManifest
|
||||
|
@ -68,7 +65,6 @@ support-files =
|
|||
test_bug462673.html
|
||||
test_bug628179.html
|
||||
test_bug839103.html
|
||||
test_bug959531.html
|
||||
test_process_flags_chrome.html
|
||||
title_test.svg
|
||||
unknownContentType_file.pif
|
||||
|
@ -91,22 +87,6 @@ support-files =
|
|||
!/toolkit/mozapps/extensions/test/xpinstall/theme.xpi
|
||||
!/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs
|
||||
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutCertError.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutNetError.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutSupport.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutSupport_newtab_security_state.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutHealthReport.js]
|
||||
skip-if = os == "linux" # Bug 924307
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutHome.js]
|
||||
skip-if = true # Bug 1374537
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_aboutHome_wrapsCorrectly.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_addKeywordSearch.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
|
|
|
@ -359,84 +359,6 @@ function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the next top-level document load in the current browser. The URI
|
||||
* of the document is compared against aExpectedURL. The load is then stopped
|
||||
* before it actually starts.
|
||||
*
|
||||
* @param aExpectedURL
|
||||
* The URL of the document that is expected to load.
|
||||
* @param aStopFromProgressListener
|
||||
* Whether to cancel the load directly from the progress listener. Defaults to true.
|
||||
* If you're using this method to avoid hitting the network, you want the default (true).
|
||||
* However, the browser UI will behave differently for loads stopped directly from
|
||||
* the progress listener (effectively in the middle of a call to loadURI) and so there
|
||||
* are cases where you may want to avoid stopping the load directly from within the
|
||||
* progress listener callback.
|
||||
* @return promise
|
||||
*/
|
||||
function waitForDocLoadAndStopIt(aExpectedURL, aBrowser = gBrowser.selectedBrowser, aStopFromProgressListener = true) {
|
||||
function content_script(contentStopFromProgressListener) {
|
||||
let { interfaces: Ci, utils: Cu } = Components;
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
let wp = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
|
||||
function stopContent(now, uri) {
|
||||
if (now) {
|
||||
/* Hammer time. */
|
||||
content.stop();
|
||||
|
||||
/* Let the parent know we're done. */
|
||||
sendAsyncMessage("Test:WaitForDocLoadAndStopIt", { uri });
|
||||
} else {
|
||||
setTimeout(stopContent.bind(null, true, uri), 0);
|
||||
}
|
||||
}
|
||||
|
||||
let progressListener = {
|
||||
onStateChange(webProgress, req, flags, status) {
|
||||
dump("waitForDocLoadAndStopIt: onStateChange " + flags.toString(16) + ": " + req.name + "\n");
|
||||
|
||||
if (webProgress.isTopLevel &&
|
||||
flags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
wp.removeProgressListener(progressListener);
|
||||
|
||||
let chan = req.QueryInterface(Ci.nsIChannel);
|
||||
dump(`waitForDocLoadAndStopIt: Document start: ${chan.URI.spec}\n`);
|
||||
|
||||
stopContent(contentStopFromProgressListener, chan.originalURI.spec);
|
||||
}
|
||||
},
|
||||
QueryInterface: XPCOMUtils.generateQI(["nsISupportsWeakReference"])
|
||||
};
|
||||
wp.addProgressListener(progressListener, wp.NOTIFY_STATE_WINDOW);
|
||||
|
||||
/**
|
||||
* As |this| is undefined and we can't extend |docShell|, adding an unload
|
||||
* event handler is the easiest way to ensure the weakly referenced
|
||||
* progress listener is kept alive as long as necessary.
|
||||
*/
|
||||
addEventListener("unload", function() {
|
||||
try {
|
||||
wp.removeProgressListener(progressListener);
|
||||
} catch (e) { /* Will most likely fail. */ }
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
function complete({ data }) {
|
||||
is(data.uri, aExpectedURL, "waitForDocLoadAndStopIt: The expected URL was loaded");
|
||||
mm.removeMessageListener("Test:WaitForDocLoadAndStopIt", complete);
|
||||
resolve();
|
||||
}
|
||||
|
||||
let mm = aBrowser.messageManager;
|
||||
mm.loadFrameScript("data:,(" + content_script.toString() + ")(" + aStopFromProgressListener + ");", true);
|
||||
mm.addMessageListener("Test:WaitForDocLoadAndStopIt", complete);
|
||||
info("waitForDocLoadAndStopIt: Waiting for URL: " + aExpectedURL);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the next load to complete in any browser or the given browser.
|
||||
* If a <tabbrowser> is given it waits for a load in any of its browsers.
|
||||
|
@ -829,7 +751,3 @@ function getCertExceptionDialog(aLocation) {
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function promiseDisableOnboardingTours() {
|
||||
return SpecialPowers.pushPrefEnv({set: [["browser.onboarding.enabled", false]]});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче