v8/test/inspector/runtime/console-message-omit-data-urls.js
Kim-Anh Tran 1e463205ea [inspector] Skip sending data urls in the Runtime domain
This skips sending the data urls along with Runtime.CallFrame,
and Runtime.ExceptionDetails.

Also-by: bmeurer@chromium.org
Bug: chromium:1132260
Change-Id: I45136bc0d3217caf8fbd93946b021f56f64f04b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2621077
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72063}
2021-01-13 13:27:41 +00:00

64 lines
1.6 KiB
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we only send along non-data urls.');
var expectedMessages = 2;
var messages = [];
Protocol.Runtime.enable();
Protocol.Console.enable();
Protocol.Runtime.onConsoleAPICalled(consoleAPICalled);
Protocol.Runtime.onExceptionThrown(exceptionThrown);
contextGroup.addScript(`
async function test() {
console.log("Hello World!");
throw new Exception("Exception thrown");
}
//# sourceURL=data:,pseudoDataUrl`);
function consoleAPICalled(result)
{
const msgText = result.params.args[0].value;
const callFrames = result.params.stackTrace.callFrames;
let messageParts = [];
messageParts.push(`console api called: ${msgText}`);
for (frame of callFrames) {
messageParts.push(` callFrame: function ${frame.functionName} (url: ${frame.url})`);
}
messages.push(messageParts.join("\n"));
if (!(--expectedMessages)) {
done();
}
}
function exceptionThrown(result)
{
const exceptionDetails = result.params.exceptionDetails;
const url = exceptionDetails.url;
const text = exceptionDetails.text;
messages.push(`exception details: ${text} (url: ${url ? url : ""})`)
if (!(--expectedMessages)) {
done();
}
}
function done()
{
messages.sort();
for (var message of messages) {
InspectorTest.log(message);
}
InspectorTest.completeTest();
}
(async function test() {
InspectorTest.log('Test log with data uri.');
await Protocol.Runtime.evaluate({ expression: `test()//# sourceURL=test.js`});
})();