Commit df6d4698 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] fixed script-parsed-hash.js test

Original intention of longScript was to check how hashing works with long
script source. Current implementation calculates hash for longString function,
it's non reliable since Function.toString is still not specified and can return
different line endings on different architectures.

TBR=dgozman@chromium.org

Bug: none
Change-Id: I4c5b6f30c2849a1a2702c74665b86ced731f1b28
Reviewed-on: https://chromium-review.googlesource.com/609486Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47268}
parent 78caf8d5
Tests scripts hasing Tests scripts hasing
Hash received: 1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18 {
Hash received: EBF1ECD351E7A3294CB5762843D429DC872EBA18 endColumn : 1
Hash received: 86A31E7131896CF01BA837945C2894385F369F24 endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18
isLiveEdit : false
isModule : false
length : 1
scriptId : <scriptId>
sourceMapURL :
startColumn : 0
startLine : 0
url : foo1.js
}
{
endColumn : 3
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : EBF1ECD351E7A3294CB5762843D429DC872EBA18
isLiveEdit : false
isModule : false
length : 3
scriptId : <scriptId>
sourceMapURL :
startColumn : 0
startLine : 0
url : foo2.js
}
{
endColumn : 8106
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 885818413D7FC3E2220B3E367FF57CB1D1572095
isLiveEdit : false
isModule : false
length : 8106
scriptId : <scriptId>
sourceMapURL :
startColumn : 0
startLine : 0
url : foo3.js
}
...@@ -2,32 +2,28 @@ ...@@ -2,32 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests scripts hasing'); let {session, contextGroup, Protocol} =
InspectorTest.start('Tests scripts hasing');
var hashes = new Set(["1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18", (async function test() {
"EBF1ECD351E7A3294CB5762843D429DC872EBA18", await Protocol.Debugger.enable();
"86A31E7131896CF01BA837945C2894385F369F24"]); await Protocol.Runtime.enable();
Protocol.Debugger.enable(); Protocol.Runtime.compileScript({
Protocol.Debugger.onScriptParsed(function(messageObject) expression: "1", sourceURL: "foo1.js", persistScript: true});
{ let {params} = await Protocol.Debugger.onceScriptParsed();
if (hashes.has(messageObject.params.hash)) InspectorTest.logMessage(params);
InspectorTest.log(`Hash received: ${messageObject.params.hash}`); Protocol.Runtime.compileScript({
else expression: "239", sourceURL: "foo2.js", persistScript: true});
InspectorTest.log(`[FAIL]: unknown hash ${messageObject.params.hash}`); ({params} = await Protocol.Debugger.onceScriptParsed());
}); InspectorTest.logMessage(params);
var script = "var b = 1;";
function longScript() { for (var i = 0; i < 2024; ++i) {
var longScript = "var b = 1;"; script += "++b;";
for (var i = 0; i < 2024; ++i) }
longScript += "++b;"; Protocol.Runtime.compileScript({
} expression: script, sourceURL: "foo3.js",
persistScript: true});
Protocol.Runtime.enable(); ({params} = await Protocol.Debugger.onceScriptParsed());
Protocol.Runtime.compileScript({ expression: "1", sourceURL: "foo1.js", persistScript: true }); InspectorTest.logMessage(params);
Protocol.Runtime.compileScript({ expression: "239", sourceURL: "foo2.js", persistScript: true });
Protocol.Runtime.compileScript({ expression: "(" + longScript + ")()", sourceURL: "foo3.js", persistScript: true }).then(step2);
function step2()
{
InspectorTest.completeTest(); InspectorTest.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