Commit c01e9b4c authored by Corentin Wallez's avatar Corentin Wallez Committed by Commit Bot

Revert "Add resource load priority Service Worker tests"

This reverts commit 0f0d0b74.

Reason for revert: super flaky on win7_chromium_rel_ng

BUG=chromium:872776

Original change's description:
> Add resource load priority Service Worker tests
> 
> This CL adds resource load priority tests ensuring that the priority of
> requests that pass through a Service Worker is preserved.
> 
> R=​kinuko@chromium.org, kouhei@chromium.org, yhirano@chromium.org
> 
> Bug: 872776
> Change-Id: I74f334359b3255fcac5c13fbdb9f1e601af0f8f0
> Reviewed-on: https://chromium-review.googlesource.com/c/1316104
> Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
> Reviewed-by: Matt Falkenhagen <falken@chromium.org>
> Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#606689}

TBR=falken@chromium.org,kinuko@chromium.org,yhirano@chromium.org,kouhei@chromium.org,domfarolino@gmail.com

Change-Id: I6d997795ffc64f1005ed3821799300cd3401eea9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 872776
Reviewed-on: https://chromium-review.googlesource.com/c/1329245Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606822}
parent 089805f4
This is a testharness.js-based test.
PASS registering service worker
PASS Requests from the Fetch API passing through a Service Worker should be loaded with kHigh priority
PASS Render-blocking style sheets requests passing through a Service Worker should be loaded with kVeryHigh priority
FAIL Async scripts passing through a Service Worker should be loaded with kLow priority assert_equals: expected 1 but got 3
FAIL Deferred scripts passing through a Service Worker should be loaded with kLow priority assert_equals: expected 1 but got 3
PASS Module scripts passing through a Service Worker should be loaded with kHigh priority
PASS XHRs passing through a Service Worker should be loaded with kHigh priority
PASS Parser-blocking scripts passing through a Service Worker should be loaded with kHigh priority
FAIL Off-screen images passing through a Service Worker should be loaded with kLow priority assert_equals: expected 1 but got 3
FAIL Prefetches passing through a Service Worker should be loaded with kLowest priority assert_equals: expected 0 but got 3
PASS unregistering service worker
Harness: the test ran to completion.
<title>ResourceLoadPriority tests through Service Worker</title>
<script src="resources/common.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/serviceworker/resources/test-helpers.js"></script>
<script>
function openWindow(url, t) {
const win = window.open(url, '_blank');
t.add_cleanup(() => win.close());
}
function resource_load_priority_service_worker_test(url, expected_priority,
description) {
promise_test(t => {
const serviceWorkerPriority = new Promise(resolve => {
navigator.serviceWorker.onmessage = resolve;
});
const subresourceFinishedLoading = new Promise(resolve => {
window.onmessage = e => {
assert_not_equals(e.data, 'FAILED',
`Resources requested in the test window ${url} should have loaded`);
resolve();
}
});
openWindow(url, t);
return Promise.all([serviceWorkerPriority, subresourceFinishedLoading])
.then(promiseValues => {
// Return the promise value associated with the service worker priority event.
return promiseValues[0];
})
.then(priority_event => {
assert_not_equals(priority_event.data, 'FAILED',
'The resource failed to load for some reason.');
assert_equals(priority_event.data, expected_priority);
});
}, description);
}
promise_test(t => {
return service_worker_unregister_and_register(t,
'service-worker-get-priority.js', '/priorities/')
.then(r => {
return wait_for_state(t, r.installing, 'activated');
});
}, 'registering service worker');
resource_load_priority_service_worker_test(
'resources/service-worker/fetch.html', kHigh,
'Requests from the Fetch API passing through a Service Worker should be ' +
'loaded with kHigh priority');
resource_load_priority_service_worker_test(
'resources/service-worker/render-blocking-stylesheet.html', kVeryHigh,
'Render-blocking style sheets requests passing through a Service Worker ' +
'should be loaded with kVeryHigh priority');
resource_load_priority_service_worker_test(
'resources/service-worker/async-script.html', kLow,
'Async scripts passing through a Service Worker should be loaded with kLow ' +
'priority');
resource_load_priority_service_worker_test(
'resources/service-worker/defer-script.html', kLow,
'Deferred scripts passing through a Service Worker should be loaded with ' +
'kLow priority');
resource_load_priority_service_worker_test(
'resources/service-worker/module-script.html', kHigh,
'Module scripts passing through a Service Worker should be loaded with ' +
'kHigh priority');
resource_load_priority_service_worker_test(
'resources/service-worker/xhr.html', kHigh,
'XHRs passing through a Service Worker should be loaded with kHigh priority');
resource_load_priority_service_worker_test(
'resources/service-worker/parser-blocking-script.html', kHigh,
'Parser-blocking scripts passing through a Service Worker should be loaded ' +
'with kHigh priority');
resource_load_priority_service_worker_test(
'resources/service-worker/off-screen-image.html', kLow,
'Off-screen images passing through a Service Worker should be loaded with ' +
'kLow priority');
resource_load_priority_service_worker_test(
'resources/service-worker/prefetch.html', kVeryLow,
'Prefetches passing through a Service Worker should be loaded with kLowest ' +
'priority');
// TODO(domfarolino): Add a synchronous XHR test when https://crbug.com/602051
// is resolved.
promise_test(t => {
return service_worker_unregister(t, '/priorities/');
}, 'unregistering service worker');
</script>
......@@ -5,8 +5,7 @@
* and in these tests, we use the below variables to represent
* the exposed values in a readable way.
*/
const kVeryLow = 0,
kLow = 1,
const kLow = 1,
kMedium = 2,
kHigh = 3,
kVeryHigh = 4;
......@@ -17,10 +16,6 @@ function reportPriority(url, optionalDoc) {
window.opener.postMessage(loadPriority, '*');
}
function reportLoaded() {
window.opener.postMessage('LOADED', '*');
}
function reportFailure() {
window.opener.postMessage('FAILED', '*');
}
<script src="../common.js"></script>
<script src="../../../resources/dummy.js?async&getPriority" async onload="reportLoaded()" onerror="reportFailure()"></script>
<script src="../common.js"></script>
<script src="../../../resources/dummy.js?defer&getPriority" defer onload="reportLoaded()" onerror="reportFailure()"></script>
<script src="../common.js"></script>
<script>
fetch('../../../resources/dummy.html?getPriority')
.then(reportLoaded, reportFailure);
</script>
<script src="../common.js"></script>
<script src="../../../resources/dummy.js?module&getPriority" type=module onload="reportLoaded()" onerror="reportFailure()"></script>
<script src="../common.js"></script>
<script>
const image = new Image();
image.src = '../../../resources/square.png?getPriority';
image.onload = reportLoaded;
image.onerror = reportFailure;
</script>
<script src="../common.js"></script>
<script src="../../../resources/dummy.js?normal&getPriority" onload="reportLoaded()" onerror="reportFailure()"></script>
<script src="../common.js"></script>
<link rel=prefetch href="../../../resources/dummy.html?getPriority" onload="reportLoaded()" onerror="reportFailure()">
<script src="../common.js"></script>
<!-- Media-matching style sheets block rendering, and are critical -->
<link rel="stylesheet" href="../../../resources/dummy.css?getPriority" onload="reportLoaded()" onerror="reportFailure()">
<script src="../common.js"></script>
<script>
const xhr = new XMLHttpRequest();
xhr.open('GET', '../../../resources/dummy.html?getPriority');
xhr.send();
xhr.onload = reportLoaded;
xhr.onerror = reportFailure;
</script>
addEventListener('fetch', e => {
if (e.request.url.endsWith('getPriority'))
e.respondWith(fetchAndMessagePriority(e.request));
});
async function fetchAndMessagePriority(request) {
const response = await fetch(request);
const priority = internals.getResourcePriority(request.url, this);
const clientArray = await clients.matchAll({includeUncontrolled: true});
clientArray.forEach(client => {
client.postMessage(priority);
});
return response;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment