Commit 71168b55 authored by Jack Franklin's avatar Jack Franklin Committed by Chromium LUCI CQ

Remove use of String#compareTo from layout tests

It's being removed in https://crrev.com/c/2627267.

Bug: chromium:1050549
Change-Id: I686d66c0fdbc00b742f6a05b6d839138954a82d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627407
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: default avatarTim van der Lippe <tvanderlippe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842957}
parent 7cee7a91
......@@ -12,7 +12,11 @@
await TestRunner.navigatePromise('resources/page.html');
await PerformanceTestRunner.stopTimeline();
for (const track of PerformanceTestRunner.timelineModel().tracks().sort((a, b) => a.url.compareTo(b.url))) {
const sortedTracks = PerformanceTestRunner.timelineModel().tracks().sort((a, b) => {
return a.url > b.url ? 1 : b.url > a.url ? -1 : 0;
})
for (const track of sortedTracks) {
if (track.type !== TimelineModel.TimelineModel.TrackType.MainThread)
continue;
TestRunner.addResult(`name: ${track.name}`);
......
......@@ -79,7 +79,7 @@
function dumpEditorTabs() {
var editorContainer = UI.panels.sources._sourcesView._editorContainer;
var openedUISourceCodes = [...editorContainer._tabIds.keys()];
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
openedUISourceCodes.sort((a, b) => a.url() > b.url() ? 1 : b.url() > a.url() ? -1 : 0);
TestRunner.addResult('Opened tabs: ');
for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url());
......
......@@ -41,7 +41,7 @@
function dumpEditorTabs() {
var editorContainer = UI.panels.sources._sourcesView._editorContainer;
var openedUISourceCodes = [...editorContainer._tabIds.keys()];
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
openedUISourceCodes.sort((a, b) => a.url > b.url ? 1 : b.url > a.url ? -1 : 0);
TestRunner.addResult('Opened tabs: ');
for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url());
......
......@@ -30,7 +30,7 @@
function dumpEditorTabs(title) {
var editorContainer = UI.panels.sources._sourcesView._editorContainer;
var openedUISourceCodes = [...editorContainer._tabIds.keys()];
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
openedUISourceCodes.sort((a, b) => a.url > b.url ? 1 : b.url > a.url ? -1 : 0);
TestRunner.addResult(title);
for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url());
......
......@@ -57,6 +57,9 @@ v8.wasm.moduleCacheHit: 2 for large.wasm
await PerformanceTestRunner.invokeWithTracing('runTests', processEvents);
function stringCompare(a, b) {
return a > b ? 1 : b > a ? -1 : 0;
}
function processEvents() {
// Since some WebAssembly compile events may be reported on different
// threads, sort events by URL and type, to get a deterministic test.
......@@ -64,8 +67,9 @@ v8.wasm.moduleCacheHit: 2 for large.wasm
let url_a = a.args['url'] || '';
let url_b = b.args['url'] || '';
if (url_a != url_b)
return url_a.compareTo(url_b);
return a.name.compareTo(b.name);
return stringCompare(url_a, url_b)
return stringCompare(a.name, b.name)
}
const event_types = new Set([
......
......@@ -392,20 +392,6 @@ const HeapSnapshotLoader = (function (exports) {
return this.substr(0, maxLength - 1) + '';
};
/**
* @param {string} other
* @return {number}
*/
String.prototype.compareTo = function(other) {
if (this > other) {
return 1;
}
if (this < other) {
return -1;
}
return 0;
};
/**
* @param {string|undefined} string
* @return {number}
......
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