Commit 4eee8e4a authored by Alex Rudenko's avatar Alex Rudenko Committed by Commit Bot

Fix flakiness in http/tests/devtools/bindings/inline-styles-binding.js

Prevents races with regards to location updates and stylesheet
updated.

Fixed: 1104333
Change-Id: I78e17444482f16f97503e8c89ea42208c01d21c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2299619Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788539}
parent ad7c7c6b
...@@ -6851,7 +6851,6 @@ crbug.com/1102167 external/wpt/fetch/redirect-navigate/preserve-fragment.html [ ...@@ -6851,7 +6851,6 @@ crbug.com/1102167 external/wpt/fetch/redirect-navigate/preserve-fragment.html [
crbug.com/1104186 [ Win ] fast/forms/color-scheme/suggestion-picker/time-suggestion-picker-appearance.html [ Pass Failure ] crbug.com/1104186 [ Win ] fast/forms/color-scheme/suggestion-picker/time-suggestion-picker-appearance.html [ Pass Failure ]
crbug.com/1104195 inspector-protocol/css/css-set-effective-property-value.js [ Pass Failure Crash ] crbug.com/1104195 inspector-protocol/css/css-set-effective-property-value.js [ Pass Failure Crash ]
crbug.com/1104333 http/tests/devtools/bindings/inline-styles-binding.js [ Pass Failure Crash ]
# Sheriff 2020-07-13 # Sheriff 2020-07-13
......
...@@ -5,11 +5,11 @@ LiveLocation 'script1' was updated 17:48 ...@@ -5,11 +5,11 @@ LiveLocation 'script1' was updated 17:48
LiveLocation 'style0' was updated 7:11 LiveLocation 'style0' was updated 7:11
LiveLocation 'style1' was updated 17:11 LiveLocation 'style1' was updated 17:11
Adding rule0 Adding rule0
LiveLocation 'style0' was updated 9:1
LiveLocation 'style1' was updated 19:11
LiveLocation 'script0' was updated 15:12 LiveLocation 'script0' was updated 15:12
LiveLocation 'script1' was updated 19:48 LiveLocation 'script1' was updated 19:48
LiveLocation 'style0' was updated 9:1
LiveLocation 'style1' was updated 19:11
Adding rule1 Adding rule1
LiveLocation 'style1' was updated 21:1
LiveLocation 'script1' was updated 21:38 LiveLocation 'script1' was updated 21:38
LiveLocation 'style1' was updated 21:1
...@@ -7,43 +7,58 @@ ...@@ -7,43 +7,58 @@
await TestRunner.loadModule('bindings_test_runner'); await TestRunner.loadModule('bindings_test_runner');
await TestRunner.navigatePromise('./resources/inline-style.html'); await TestRunner.navigatePromise('./resources/inline-style.html');
var uiSourceCode = await TestRunner.waitForUISourceCode('inline-style.html', Workspace.projectTypes.Network); const uiSourceCode = await TestRunner.waitForUISourceCode('inline-style.html', Workspace.projectTypes.Network);
await uiSourceCode.requestContent(); // prefetch content to fix flakiness await uiSourceCode.requestContent(); // prefetch content to fix flakiness
var styleSheets = TestRunner.cssModel.styleSheetIdsForURL(uiSourceCode.url()); const headers = TestRunner.cssModel.headersForSourceURL(uiSourceCode.url());
var scripts = TestRunner.debuggerModel.scriptsForSourceURL(uiSourceCode.url()); // Sort headers in the order they appear in the file to avoid flakiness.
var locationPool = new Bindings.LiveLocationPool(); headers.sort((a, b) => a.startLine - b.startLine);
var i = 0; const styleSheets = headers.map(header => header.id);
for (var script of scripts) { const scripts = TestRunner.debuggerModel.scriptsForSourceURL(uiSourceCode.url());
var rawLocation = TestRunner.debuggerModel.createRawLocation(script, script.lineOffset, script.columnOffset); const locationPool = new Bindings.LiveLocationPool();
let i = 0;
const locationUpdates = new Map();
for (const script of scripts) {
const rawLocation = TestRunner.debuggerModel.createRawLocation(script, script.lineOffset, script.columnOffset);
await Bindings.debuggerWorkspaceBinding.createLiveLocation( await Bindings.debuggerWorkspaceBinding.createLiveLocation(
rawLocation, updateDelegate.bind(null, 'script' + i), locationPool); rawLocation, updateDelegate.bind(null, 'script' + i), locationPool);
i++; i++;
} }
i = 0; i = 0;
for (var styleSheetId of styleSheets) { for (const styleSheetId of styleSheets) {
var header = TestRunner.cssModel.styleSheetHeaderForId(styleSheetId); const header = TestRunner.cssModel.styleSheetHeaderForId(styleSheetId);
var rawLocation = new SDK.CSSLocation(header, header.startLine, header.startColumn); const rawLocation = new SDK.CSSLocation(header, header.startLine, header.startColumn);
await Bindings.cssWorkspaceBinding.createLiveLocation( await Bindings.cssWorkspaceBinding.createLiveLocation(
rawLocation, updateDelegate.bind(null, 'style' + i), locationPool); rawLocation, updateDelegate.bind(null, 'style' + i), locationPool);
i++; i++;
} }
await TestRunner.waitForPendingLiveLocationUpdates();
printLocationUpdates();
i = 0; i = 0;
for (var styleSheetId of styleSheets) { for (const styleSheetId of styleSheets) {
TestRunner.addResult('Adding rule' + i) TestRunner.addResult('Adding rule' + i)
await TestRunner.cssModel.addRule(styleSheetId, `.new-rule { await TestRunner.cssModel.addRule(styleSheetId, `.new-rule {
--new: true; --new: true;
}`, TextUtils.TextRange.createFromLocation(0, 0)); }`, TextUtils.TextRange.createFromLocation(0, 0));
await TestRunner.waitForPendingLiveLocationUpdates(); await TestRunner.waitForPendingLiveLocationUpdates();
printLocationUpdates();
i++; i++;
} }
async function updateDelegate(name, location) { async function updateDelegate(name, location) {
var uiLocation = await location.uiLocation(); const uiLocation = await location.uiLocation();
TestRunner.addResult(`LiveLocation '${name}' was updated ${uiLocation.lineNumber}:${uiLocation.columnNumber}`); locationUpdates.set(name, `LiveLocation '${name}' was updated ${uiLocation.lineNumber}:${uiLocation.columnNumber}`);
}
function printLocationUpdates() {
const keys = [...locationUpdates.keys()].sort();
for (const key of keys) {
TestRunner.addResult(locationUpdates.get(key));
}
locationUpdates.clear();
} }
TestRunner.completeTest(); TestRunner.completeTest();
......
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