Bug 1455405 fix intermittent by using real events, r=rpl

This test was testing that files are loaded/executed/etc in the page, but
what we really care about is that the webrequest api works.  Other tests
are responsible for stuff like css and js actually work.  The patch does
maintain (fixed) the js test, but removes the css test for lack of a good
way to properly wait for css to apply.

MozReview-Commit-ID: B2uByaxNeK2

--HG--
extra : rebase_source : 6779116f9f1a4a7ce24cd32c3648d1027343db93
This commit is contained in:
Shane Caraveo 2018-07-16 09:08:30 -03:00
Родитель 2ec98e736f
Коммит 43b464a409
3 изменённых файлов: 27 добавлений и 21 удалений

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

@ -1,3 +1,12 @@
"use strict";
window.success = window.success ? window.success + 1 : 1;
{
let scripts = document.getElementsByTagName("script");
let url = new URL(scripts[scripts.length - 1].src);
let flag = url.searchParams.get("q");
if (flag) {
window.postMessage(flag, "*");
}
}

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

@ -125,7 +125,7 @@ skip-if = (os == 'android' && debug) || (verify && (os == 'linux' || os == 'mac'
skip-if = os == 'android'
[test_ext_webrequest_background_events.html]
[test_ext_webrequest_basic.html]
skip-if = os == 'android' && debug || (os == 'linux' && !asan) # bug 1397615, bug 1455405
skip-if = os == 'android' && debug # bug 1397615
[test_ext_webrequest_errors.html]
[test_ext_webrequest_filter.html]
skip-if = os == 'android' && debug # bug 1452348

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

@ -12,10 +12,14 @@
<script>
"use strict";
function spinEventLoop() {
return new Promise((resolve, reject) => {
window.requestIdleCallback(() => {
resolve();
function promiseWindowEvent(name, accept) {
return new Promise(resolve => {
window.addEventListener(name, function listener(event) {
if (event.data !== accept) {
return;
}
window.removeEventListener(name, listener);
resolve(event);
});
});
}
@ -80,11 +84,6 @@ add_task(async function test_webRequest_links() {
// we redirect to style_good which completes the test
addStylesheet("file_style_redirect.css");
await extension.awaitMessage("done");
// waiting for CSS applied.
await spinEventLoop();
let style = window.getComputedStyle(document.getElementById("test"));
is(style.getPropertyValue("color"), "rgb(255, 0, 0)", "Good CSS loaded");
});
add_task(async function test_webRequest_images() {
@ -132,16 +131,14 @@ add_task(async function test_webRequest_scripts() {
};
extension.sendMessage("set-expected", {expect, origin: location.href});
await extension.awaitMessage("continue");
let message = promiseWindowEvent("message", "test1");
addScript("file_script_bad.js");
await extension.awaitMessage("cancelled");
// we redirect to script_good which completes the test
addScript("file_script_redirect.js");
addScript("file_script_redirect.js?q=test1");
await extension.awaitMessage("done");
// wait for JS executed
await spinEventLoop();
is(window.success, 1, "Good script ran");
is(window.failure, undefined, "Failure script didn't run");
is((await message).data, "test1", "good script ran");
});
add_task(async function test_webRequest_xhr_get() {
@ -195,16 +192,16 @@ add_task(async function test_webRequest_checkCached() {
};
extension.sendMessage("set-expected", {expect, origin: location.href});
await extension.awaitMessage("continue");
let message = promiseWindowEvent("message", "test1");
addImage("file_image_good.png");
addScript("file_script_good.js");
addScript("file_script_good.js?q=test1");
is((await message).data, "test1", "good script ran");
addStylesheet("file_style_good.css");
addScript("nonexistent_script_url.js");
await extension.awaitMessage("done");
// wait for JS executed
await spinEventLoop();
is(window.success, 2, "Good script ran");
is(window.failure, undefined, "Failure script didn't run");
});
add_task(async function test_webRequest_headers() {