Commit 46451301 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Deflake http/tests/devtools/isolated-code-cache/same-origin-test.js

The test was flaky because the ScriptResource can be
garbage collected before the test finished.

This CL keeps the ScriptResource alive, by loading the
script as a parser-inserted script.
This uses a Blink-specific behavior -- a parser-inserted
<script> keeps alive its corresponding ScriptResource
but a dynamically-inserted <script> doesn't.
This is somehow hacky, but seems to work.

Bug: 841466, 906320, 927296, 922951
Change-Id: Ia45787d917191d81917e89f6843ad8b0cbcc7e76
Reviewed-on: https://chromium-review.googlesource.com/c/1475077Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632755}
parent d54a103e
...@@ -5740,8 +5740,6 @@ crbug.com/907862 [ Mac10.13 ] gamepad/multiple-event-listeners.html [ Pass Failu ...@@ -5740,8 +5740,6 @@ crbug.com/907862 [ Mac10.13 ] gamepad/multiple-event-listeners.html [ Pass Failu
# Sheriff 2018-11-23 # Sheriff 2018-11-23
crbug.com/874162 virtual/mouseevent_fractional/fast/events/middleClickAutoscroll-event-fired.html [ Skip ] crbug.com/874162 virtual/mouseevent_fractional/fast/events/middleClickAutoscroll-event-fired.html [ Skip ]
crbug.com/906320 virtual/not-site-per-process/http/tests/devtools/isolated-code-cache/same-origin-test.js [ Failure Pass ]
crbug.com/906320 [ Mac10.13 ] virtual/site-isolated-code-cache/http/tests/devtools/isolated-code-cache/same-origin-test.js [ Failure Pass ]
# Sheriff 2018-11-26 # Sheriff 2018-11-26
crbug.com/908276 [ Mac ] external/wpt/webstorage/storage_setitem.html [ Pass Timeout ] crbug.com/908276 [ Mac ] external/wpt/webstorage/storage_setitem.html [ Pass Timeout ]
...@@ -5914,7 +5912,6 @@ crbug.com/922951 fast/scroll-snap/snaps-for-different-key-granularity.html [ Ski ...@@ -5914,7 +5912,6 @@ crbug.com/922951 fast/scroll-snap/snaps-for-different-key-granularity.html [ Ski
crbug.com/922951 fast/text/international/inline-plaintext-relayout-with-leading-neutrals.html [ Skip ] crbug.com/922951 fast/text/international/inline-plaintext-relayout-with-leading-neutrals.html [ Skip ]
crbug.com/922951 http/tests/cache/subresource-fragment-identifier.html [ Skip ] crbug.com/922951 http/tests/cache/subresource-fragment-identifier.html [ Skip ]
crbug.com/922951 http/tests/devtools/audits2/audits2-successful-run.js [ Skip ] crbug.com/922951 http/tests/devtools/audits2/audits2-successful-run.js [ Skip ]
crbug.com/922951 http/tests/devtools/isolated-code-cache/same-origin-test.js [ Skip ]
crbug.com/922951 http/tests/devtools/tracing-session-id.js [ Skip ] crbug.com/922951 http/tests/devtools/tracing-session-id.js [ Skip ]
crbug.com/922951 http/tests/devtools/tracing/console-timeline.js [ Skip ] crbug.com/922951 http/tests/devtools/tracing/console-timeline.js [ Skip ]
crbug.com/922951 http/tests/devtools/tracing/timeline-network-received-data.js [ Skip ] crbug.com/922951 http/tests/devtools/tracing/timeline-network-received-data.js [ Skip ]
...@@ -6028,8 +6025,6 @@ crbug.com/926311 external/wpt/wasm/jsapi/constructor/compile.any.worker.html [ P ...@@ -6028,8 +6025,6 @@ crbug.com/926311 external/wpt/wasm/jsapi/constructor/compile.any.worker.html [ P
crbug.com/v8/8319 external/wpt/wasm/jsapi/module/customSections.any.html [ Pass Failure ] crbug.com/v8/8319 external/wpt/wasm/jsapi/module/customSections.any.html [ Pass Failure ]
crbug.com/v8/8319 external/wpt/wasm/jsapi/module/customSections.any.worker.html [ Pass Failure ] crbug.com/v8/8319 external/wpt/wasm/jsapi/module/customSections.any.worker.html [ Pass Failure ]
crbug.com/927296 virtual/wasm-site-isolated-code-cache/http/tests/devtools/wasm-isolated-code-cache/wasm-cache-test.js [ Pass Failure ]
# Disabled until FreezeFramesOnVisiblity feature enabled by default. # Disabled until FreezeFramesOnVisiblity feature enabled by default.
crbug.com/907125 external/wpt/lifecycle/child-display-none.tentative.html [ Skip ] crbug.com/907125 external/wpt/lifecycle/child-display-none.tentative.html [ Skip ]
......
<script charset="UTF-8" src="http://localhost:8000/devtools/resources/v8-cache-script.cgi"></script>
<script charset="UTF-8" src="/devtools/resources/v8-cache-script.cgi"></script>
...@@ -8,13 +8,13 @@ v8.compile Properties: ...@@ -8,13 +8,13 @@ v8.compile Properties:
lineNumber : 0 lineNumber : 0
notStreamedReason : "script too small" notStreamedReason : "script too small"
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties: v8.compile Properties:
{ {
data : { data : {
...@@ -22,13 +22,13 @@ v8.compile Properties: ...@@ -22,13 +22,13 @@ v8.compile Properties:
lineNumber : 0 lineNumber : 0
notStreamedReason : "already used streamed data" notStreamedReason : "already used streamed data"
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties: v8.compile Properties:
{ {
data : { data : {
...@@ -38,13 +38,13 @@ v8.compile Properties: ...@@ -38,13 +38,13 @@ v8.compile Properties:
notStreamedReason : "already used streamed data" notStreamedReason : "already used streamed data"
producedCacheSize : <number> producedCacheSize : <number>
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties: v8.compile Properties:
{ {
data : { data : {
...@@ -55,13 +55,13 @@ v8.compile Properties: ...@@ -55,13 +55,13 @@ v8.compile Properties:
lineNumber : 0 lineNumber : 0
notStreamedReason : "already used streamed data" notStreamedReason : "already used streamed data"
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties: v8.compile Properties:
{ {
data : { data : {
...@@ -69,13 +69,13 @@ v8.compile Properties: ...@@ -69,13 +69,13 @@ v8.compile Properties:
lineNumber : 0 lineNumber : 0
notStreamedReason : "script too small" notStreamedReason : "script too small"
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties: v8.compile Properties:
{ {
data : { data : {
...@@ -86,12 +86,29 @@ v8.compile Properties: ...@@ -86,12 +86,29 @@ v8.compile Properties:
lineNumber : 0 lineNumber : 0
notStreamedReason : "already used streamed data" notStreamedReason : "already used streamed data"
streamed : <boolean> streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js url : .../devtools/resources/v8-cache-script.cgi
} }
endTime : <number> endTime : <number>
startTime : <number> startTime : <number>
type : "v8.compile" type : "v8.compile"
} }
Text details for v8.compile: v8-cache-script.js:1 Text details for v8.compile: v8-cache-script.cgi:1
v8.compile Properties:
{
data : {
cacheConsumeOptions : "code"
cacheRejected : false
columnNumber : 0
consumedCacheSize : <number>
lineNumber : 0
notStreamedReason : "script too small"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compile"
}
Text details for v8.compile: v8-cache-script.cgi:1
----------------------------------------------- -----------------------------------------------
...@@ -11,51 +11,48 @@ ...@@ -11,51 +11,48 @@
// scripts in the cache. // scripts in the cache.
SDK.multitargetNetworkManager.clearBrowserCache(); SDK.multitargetNetworkManager.clearBrowserCache();
await TestRunner.evaluateInPagePromise(` // There are two scripts:
function loadScript() { // [A] http://127.0.0.1:8000/devtools/resources/v8-cache-script.cgi
const url = 'http://localhost:8000/devtools/resources/v8-cache-script.js'; // [B] http://localhost:8000/devtools/resources/v8-cache-script.cgi
const frameId = 'frame_id';
let iframeWindow = document.getElementById(frameId).contentWindow; // An iframe that loads [A].
return iframeWindow.loadScript(url) // The script is executed as a parser-inserted script,
.then(() => iframeWindow.loadScript(url)) // to keep the ScriptResource on the MemoryCache.
.then(() => iframeWindow.loadScript(url)); // ScriptResources for dynamically-inserted <script>s can be
} // garbage-collected and thus removed from MemoryCache after its execution.
function differentURLLoadScript() { const scope = 'resources/same-origin-script.html';
const url = 'http://127.0.0.1:8000/devtools/resources/v8-cache-script.js'; // An iframe that loads [B].
const frameId = 'diff_url_frame'; const scopeCrossOrigin = 'resources/cross-origin-script.html';
let iframeWindow = document.getElementById(frameId).contentWindow;
return iframeWindow.loadScript(url);
}
function sameURLLoadScript() {
const url = 'http://localhost:8000/devtools/resources/v8-cache-script.js';
const frameId = 'same_url_frame';
let iframeWindow = document.getElementById(frameId).contentWindow;
return iframeWindow.loadScript(url);
}
`);
const scope = 'http://127.0.0.1:8000/devtools/service-workers/resources/v8-cache-iframe.html';
const frameId = 'frame_id';
const different_url_frameId = 'diff_url_frame';
const same_url_frameId = 'same_url_frame';
await TestRunner.addIframe(scope, {id: frameId});
await TestRunner.addIframe(scope, {id: different_url_frameId});
await TestRunner.addIframe(scope, {id: same_url_frameId});
TestRunner.addResult('--- Trace events related to code caches ------'); TestRunner.addResult('--- Trace events related to code caches ------');
await PerformanceTestRunner.startTimeline(); await PerformanceTestRunner.startTimeline();
// This loads the same script thrice. With the current V8 heuristics (defined
// Load [A] thrice. With the current V8 heuristics (defined
// in third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc) we produce // in third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc) we produce
// cache on second fetch and consume it in the third fetch. This tests these // cache on second fetch and consume it in the third fetch. This tests these
// heuristics. // heuristics.
await TestRunner.callFunctionInPageAsync('loadScript'); // Note that addIframe() waits for iframe's load event, which waits for the
// <script> loading.
// Load from a different origin should not use the cached code await TestRunner.addIframe(scope);
await TestRunner.callFunctionInPageAsync('differentURLLoadScript'); await TestRunner.addIframe(scope);
await TestRunner.addIframe(scope);
// Loading from the same origin should use cached code
await TestRunner.callFunctionInPageAsync('sameURLLoadScript'); // Load [B]. Should not use the cached code.
await TestRunner.addIframe(scopeCrossOrigin);
// Load [A] again from MemoryCache. Should use cached code.
await TestRunner.addIframe(scope);
// Clear [A] from MemoryCache. Blink evicts previous Resource when a
// new request to the same URL but with different resource type is started.
// We fetch() to the URL of [A], and thus evicts the previous ScriptResource
// of [A].
await TestRunner.evaluateInPageAsync(
`fetch('/devtools/resources/v8-cache-script.cgi')`);
// Load [A] from Disk Cache. As we cleared [A] from MemoryCache, this
// doesn't hit MemoryCache, but still hits Disk Cache.
await TestRunner.addIframe(scope);
await PerformanceTestRunner.stopTimeline(); await PerformanceTestRunner.stopTimeline();
PerformanceTestRunner.printTimelineRecordsWithDetails( PerformanceTestRunner.printTimelineRecordsWithDetails(
......
#!/usr/bin/perl -wT
print <<EOM;
Content-Type: text/javascript
Access-Control-Allow-Origin: *
Cache-Control: private, max-age=1000
// So sorry about this waste of bytes:
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
// Filler comment, to trigger code caching heuristic (script > 1K.)
EOM
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