Bug 1408944 - Rewrite and enable browser_webconsole_network_requests_from_chrome.js; r=nchevobbe

MozReview-Commit-ID: EPzTQhqhVFE

--HG--
extra : rebase_source : 8d11053f774e9465c4fb3c454f497aa3fba9534e
This commit is contained in:
Patrick Brosset 2017-11-22 16:16:03 +01:00
Родитель aa42a358a6
Коммит 4017828894
2 изменённых файлов: 26 добавлений и 30 удалений

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

@ -359,7 +359,6 @@ skip-if = true # Bug 1408943
[browser_webconsole_network_messages_expand.js]
[browser_webconsole_network_messages_openinnet.js]
[browser_webconsole_network_requests_from_chrome.js]
skip-if = true # Bug 1408944
[browser_webconsole_nodes_highlight.js]
[browser_webconsole_nodes_select.js]
[browser_webconsole_notifications.js]

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

@ -10,43 +10,40 @@
const TEST_URI = "http://example.com/";
var good = true;
var listener = {
QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ]),
observe: function (subject) {
if (subject instanceof Ci.nsIScriptError &&
subject.category === "XPConnect JavaScript" &&
subject.sourceName.includes("webconsole")) {
good = false;
add_task(async function () {
// Start a listener on the console service.
let good = true;
const listener = {
QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver ]),
observe: function (subject) {
if (subject instanceof Ci.nsIScriptError &&
subject.category === "XPConnect JavaScript" &&
subject.sourceName.includes("webconsole")) {
good = false;
}
}
}
};
var xhr;
function test() {
};
Services.console.registerListener(listener);
// trigger a lazy-load of the HUD Service
HUDService;
xhr = new XMLHttpRequest();
xhr.addEventListener("load", xhrComplete);
xhr.open("GET", TEST_URI, true);
xhr.send(null);
}
await sendRequestFromChrome();
function xhrComplete() {
xhr.removeEventListener("load", xhrComplete);
window.setTimeout(checkForException, 0);
}
function checkForException() {
ok(good, "no exception was thrown when sending a network request from a " +
"chrome window");
ok(good, "No exception was thrown when sending a network request from a chrome window");
Services.console.unregisterListener(listener);
listener = xhr = null;
});
finishTest();
function sendRequestFromChrome() {
return new Promise(resolve => {
const xhr = new XMLHttpRequest();
xhr.addEventListener("load", () => {
window.setTimeout(resolve, 0);
}, { once: true });
xhr.open("GET", TEST_URI, true);
xhr.send(null);
});
}