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
# Sheriff 2018-11-23
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
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
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/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/console-timeline.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
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/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.
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:
lineNumber : 0
notStreamedReason : "script too small"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 : {
......@@ -22,13 +22,13 @@ v8.compile Properties:
lineNumber : 0
notStreamedReason : "already used streamed data"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 : {
......@@ -38,13 +38,13 @@ v8.compile Properties:
notStreamedReason : "already used streamed data"
producedCacheSize : <number>
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 : {
......@@ -55,13 +55,13 @@ v8.compile Properties:
lineNumber : 0
notStreamedReason : "already used streamed data"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 : {
......@@ -69,13 +69,13 @@ v8.compile Properties:
lineNumber : 0
notStreamedReason : "script too small"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 : {
......@@ -86,12 +86,29 @@ v8.compile Properties:
lineNumber : 0
notStreamedReason : "already used streamed data"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.js
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
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 @@
// scripts in the cache.
SDK.multitargetNetworkManager.clearBrowserCache();
await TestRunner.evaluateInPagePromise(`
function loadScript() {
const url = 'http://localhost:8000/devtools/resources/v8-cache-script.js';
const frameId = 'frame_id';
let iframeWindow = document.getElementById(frameId).contentWindow;
return iframeWindow.loadScript(url)
.then(() => iframeWindow.loadScript(url))
.then(() => iframeWindow.loadScript(url));
}
function differentURLLoadScript() {
const url = 'http://127.0.0.1:8000/devtools/resources/v8-cache-script.js';
const frameId = 'diff_url_frame';
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});
// There are two scripts:
// [A] http://127.0.0.1:8000/devtools/resources/v8-cache-script.cgi
// [B] http://localhost:8000/devtools/resources/v8-cache-script.cgi
// An iframe that loads [A].
// The script is executed as a parser-inserted script,
// to keep the ScriptResource on the MemoryCache.
// ScriptResources for dynamically-inserted <script>s can be
// garbage-collected and thus removed from MemoryCache after its execution.
const scope = 'resources/same-origin-script.html';
// An iframe that loads [B].
const scopeCrossOrigin = 'resources/cross-origin-script.html';
TestRunner.addResult('--- Trace events related to code caches ------');
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
// cache on second fetch and consume it in the third fetch. This tests these
// heuristics.
await TestRunner.callFunctionInPageAsync('loadScript');
// Load from a different origin should not use the cached code
await TestRunner.callFunctionInPageAsync('differentURLLoadScript');
// Loading from the same origin should use cached code
await TestRunner.callFunctionInPageAsync('sameURLLoadScript');
// Note that addIframe() waits for iframe's load event, which waits for the
// <script> loading.
await TestRunner.addIframe(scope);
await TestRunner.addIframe(scope);
await TestRunner.addIframe(scope);
// 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();
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