Commit bc0fc708 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Deflake memory-cache.html.

CompositorImageAnimation changed some timings and the resource was not
yet cached when the test was expecting it to be. I've rearranged the
test and it seems to pass reliably now on Linux: it passes 100
iterations whereas it would fail within 10 iterations previously.

R=nhiroki

Bug: 813468
Change-Id: I5b76353f90e728981922c325486fa1700e85f73e
Reviewed-on: https://chromium-review.googlesource.com/945708
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540777}
parent ba269403
...@@ -3367,8 +3367,6 @@ crbug.com/417782 virtual/disable-spv175/paint/invalidation/window-resize/window- ...@@ -3367,8 +3367,6 @@ crbug.com/417782 virtual/disable-spv175/paint/invalidation/window-resize/window-
# End of Root Layer Scrolling expectations # End of Root Layer Scrolling expectations
################################################################################ ################################################################################
crbug.com/813468 [ Mac ] virtual/navigation-mojo-response/http/tests/serviceworker/chromium/memory-cache.html [ Failure Pass ]
crbug.com/794338 media/video-rotation.html [ Skip ] crbug.com/794338 media/video-rotation.html [ Skip ]
crbug.com/811605 media/video-poster-after-loadedmetadata.html [ Failure Pass ] crbug.com/811605 media/video-poster-after-loadedmetadata.html [ Failure Pass ]
...@@ -3380,8 +3378,6 @@ crbug.com/802835 virtual/outofblink-cors/external/wpt/fetch/corb/script-html-cor ...@@ -3380,8 +3378,6 @@ crbug.com/802835 virtual/outofblink-cors/external/wpt/fetch/corb/script-html-cor
crbug.com/813704 [ Win7 Mac ] http/tests/images/png-partial-load-as-document.html [ Failure Pass ] crbug.com/813704 [ Win7 Mac ] http/tests/images/png-partial-load-as-document.html [ Failure Pass ]
crbug.com/815050 [ Mac ] http/tests/serviceworker/chromium/memory-cache.html [ Failure Pass ]
crbug.com/806645 [ Win7 ] http/tests/devtools/elements/elements-panel-rewrite-href.js [ Failure Pass ] crbug.com/806645 [ Win7 ] http/tests/devtools/elements/elements-panel-rewrite-href.js [ Failure Pass ]
crbug.com/813216 [ Win7 ] http/tests/devtools/elements/styles-3/style-rule-from-imported-stylesheet.js [ Failure Pass ] crbug.com/813216 [ Win7 ] http/tests/devtools/elements/styles-3/style-rule-from-imported-stylesheet.js [ Failure Pass ]
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!-- This test should not be upstreamed to WPT because it tests the
Blink-specific memory cache and uses internals API to do that. -->
<title>Service Worker: Memory Cache</title> <title>Service Worker: Memory Cache</title>
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
...@@ -11,64 +13,60 @@ function getJSONP(url) { ...@@ -11,64 +13,60 @@ function getJSONP(url) {
var sc = document.createElement('script'); var sc = document.createElement('script');
sc.src = url; sc.src = url;
document.body.appendChild(sc); document.body.appendChild(sc);
return new Promise(function(resolve) { return new Promise(resolve => {
// This callback function is called by appending a script element. // This callback function is called by appending a script element.
callback = function(data) { resolve(data); } callback = function(data) { resolve(data); }
}); });
} }
async_test(function(t) { promise_test(t => {
var scope = 'resources/memory-cache-controlled.html'; var scope = 'resources/memory-cache-controlled.html';
var worker = 'resources/memory-cache-worker.js'; var worker = 'resources/memory-cache-worker.js';
var json_url = '/serviceworker/chromium/resources/memory-cache.jsonp'; var json_url = '/serviceworker/chromium/resources/memory-cache.jsonp';
var registration; var registration;
var frame; var frame;
var promises = [];
service_worker_unregister_and_register(t, worker, scope) return service_worker_unregister_and_register(t, worker, scope)
.then(function(r) { .then(r => {
registration = r; registration = r;
return wait_for_state(t, r.installing, 'activated'); return wait_for_state(t, r.installing, 'activated');
}) })
.then(function() { return with_iframe(scope); }) .then(() => { return with_iframe(scope); })
.then(function(f) { .then(f => {
frame = f; frame = f;
// Request a json file from controlled page. // Request a json file from controlled page.
assert_false( assert_false(
frame.contentWindow.internals.isLoadingFromMemoryCache(json_url), frame.contentWindow.internals.isLoadingFromMemoryCache(json_url),
'Cache for controlled page should be empty'); 'Cache for controlled page should be empty');
promises.push(frame.contentWindow.getJSONP(json_url)); return frame.contentWindow.getJSONP(json_url);
})
.then(result => {
assert_equals(
result.src,
'service worker',
'Response for controlled page should be served by Service Worker');
assert_true(
frame.contentWindow.internals.isLoadingFromMemoryCache(json_url),
'Response for controlled page should be cached');
// Request a json file from non-controlled page. // Request a json file from non-controlled page.
assert_false( assert_false(
internals.isLoadingFromMemoryCache(json_url), internals.isLoadingFromMemoryCache(json_url),
'Cache for non-controlled page should be empty'); 'Cache for non-controlled page should be empty');
promises.push(getJSONP(json_url)); return getJSONP(json_url);
return Promise.all(promises);
}) })
.then(function(results) { .then(result => {
assert_equals( assert_equals(
results[0].src, result.src,
'service worker',
'Response for controlled page should be served by Service Worker');
assert_equals(
results[1].src,
'network', 'network',
'Response for non-controlled page should be served by network'); 'Response for non-controlled page should be served by network');
assert_true(
frame.contentWindow.internals.isLoadingFromMemoryCache(json_url),
'Response for controlled page should be cached');
assert_true( assert_true(
internals.isLoadingFromMemoryCache(json_url), internals.isLoadingFromMemoryCache(json_url),
'Response for non-controlled page should be cached'); 'Response for non-controlled page should be cached');
frame.remove(); frame.remove();
return registration.unregister(); return registration.unregister();
}) });
.then(function() {
t.done();
})
.catch(unreached_rejection(t));
}, 'Non-controlled page should not use a cache filled by Service Worker'); }, 'Non-controlled page should not use a cache filled by Service Worker');
</script> </script>
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