Bug 1191597 part 1 - Add head.js and dummy page for browser chrome test. r=smaug

--HG--
extra : source : 1cf0a54ddb55b0434fa44851bf11be7415d0a27d
This commit is contained in:
Xidorn Quan 2016-01-11 09:38:53 +11:00
Родитель f573bf4e6c
Коммит 1565a19749
3 изменённых файлов: 66 добавлений и 0 удалений

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

@ -1,8 +1,10 @@
[DEFAULT]
support-files =
bug592641_img.jpg
dummy_page.html
file_bug649778.html
file_bug649778.html^headers^
head.js
[browser_bug592641.js]
[browser_bug649778.js]

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

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dummy test page</title>
<meta charset="utf-8"/>
</head>
<body>
<p>Dummy test page</p>
</body>
</html>

54
dom/html/test/head.js Normal file
Просмотреть файл

@ -0,0 +1,54 @@
function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
}
function promiseWaitForEvent(object, eventName, capturing = false, chrome = false) {
return new Promise((resolve) => {
function listener(event) {
info("Saw " + eventName);
object.removeEventListener(eventName, listener, capturing, chrome);
resolve(event);
}
info("Waiting for " + eventName);
object.addEventListener(eventName, listener, capturing, chrome);
});
}
/**
* 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.
*
* @return promise
*/
function waitForDocLoadComplete(aBrowser=gBrowser) {
return new Promise(resolve => {
let listener = {
onStateChange: function (webProgress, req, flags, status) {
let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
Ci.nsIWebProgressListener.STATE_STOP;
info("Saw state " + flags.toString(16) + " and status " + status.toString(16));
// When a load needs to be retargetted to a new process it is cancelled
// with NS_BINDING_ABORTED so ignore that case
if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) {
aBrowser.removeProgressListener(this);
waitForDocLoadComplete.listeners.delete(this);
let chan = req.QueryInterface(Ci.nsIChannel);
info("Browser loaded " + chan.originalURI.spec);
resolve();
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference])
};
aBrowser.addProgressListener(listener);
waitForDocLoadComplete.listeners.add(listener);
info("Waiting for browser load");
});
}
// Keep a set of progress listeners for waitForDocLoadComplete() to make sure
// they're not GC'ed before we saw the page load.
waitForDocLoadComplete.listeners = new Set();
registerCleanupFunction(() => waitForDocLoadComplete.listeners.clear());