Commit 36080ca0 authored by Kim-Anh Tran's avatar Kim-Anh Tran Committed by Commit Bot

Add layout test for setting breakpoints while blocking main thread

Bug: chromium:1076337
Change-Id: Ia5007fee42bc4b1859c0c93e89cebb89d31ed740
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2290631Reviewed-by: default avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787875}
parent 8e581b96
<!--
Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<html>
<script>
const sab = new SharedArrayBuffer(1024);
const sharedArray = new Int32Array(sab);
const worker = new Worker('blocking-main-thread.js');
worker.postMessage(sab);
function checkWorkerReady() {
// Wait for the worker to start execution.
if (sharedArray[0] === 1) {
// Enter blocking loop, and wait for an update before exiting.
while (sharedArray[2] != 1) Atomics.notify(sharedArray, 1, 1);
} else {
setTimeout(checkWorkerReady, 0);
}
}
// Let worker start execution.
setTimeout(checkWorkerReady, 0);
</script>
</html>
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
self.addEventListener('message', (m) => {
const sharedArray = new Int32Array(m.data);
var i = 0;
// Notify main thread that execution started.
Atomics.store(sharedArray, i++, 1);
// Wait for the main thread to enter the blocking loop.
Atomics.wait(sharedArray, i++, 1);
// Make the update for the main thread to exit the loop.
Atomics.store(sharedArray, i, 1);
});
\ No newline at end of file
Tests setting breakpoint when main thread blocks.
Running: testSetBreakpoint
Breakpoint sidebar pane
blocking-main-thread.js:13checked Atomics.store(sharedArray, i, 1);
Reloading page.
Page reloaded.
Script execution paused.
Breakpoint sidebar pane
blocking-main-thread.html:11checked worker.postMessage(sab);
blocking-main-thread.js:13checked breakpoint hit Atomics.store(sharedArray, i, 1);
Script execution resumed.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests setting breakpoint when main thread blocks.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
await TestRunner.navigatePromise('resources/blocking-main-thread.html');
SourcesTestRunner.runDebuggerTestSuite([
async function testSetBreakpoint(next) {
// The debugger plugin needs to be retrieved before pausing, otherwise we
// cannot set a breakpoint on the main thread during pause.
var mainThreadSource = await SourcesTestRunner.showScriptSourcePromise(
'blocking-main-thread.html');
const plugin = SourcesTestRunner.debuggerPlugin(mainThreadSource);
SourcesTestRunner.showScriptSource(
'blocking-main-thread.js', didShowWorkerSource);
async function didShowWorkerSource(sourceFrame) {
await SourcesTestRunner.createNewBreakpoint(sourceFrame, 12, '', true);
await SourcesTestRunner.waitBreakpointSidebarPane();
SourcesTestRunner.dumpBreakpointSidebarPane();
SourcesTestRunner.waitUntilPaused(paused);
TestRunner.addResult('Reloading page.');
TestRunner.reloadPage();
}
async function paused() {
plugin._createNewBreakpoint(10, '', true);
await SourcesTestRunner.waitBreakpointSidebarPane();
SourcesTestRunner.dumpBreakpointSidebarPane();
next();
}
}
]);
})();
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