[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/609486
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47268}
This commit is contained in:
Alexey Kozyatinskiy 2017-08-09 23:28:26 -07:00 committed by Commit Bot
parent 78caf8d5fe
commit df6d46983f
2 changed files with 68 additions and 30 deletions

View File

@ -1,4 +1,46 @@
Tests scripts hasing
Hash received: 1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18
Hash received: EBF1ECD351E7A3294CB5762843D429DC872EBA18
Hash received: 86A31E7131896CF01BA837945C2894385F369F24
{
endColumn : 1
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
}

View File

@ -2,32 +2,28 @@
// 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('Tests scripts hasing');
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests scripts hasing');
var hashes = new Set(["1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18",
"EBF1ECD351E7A3294CB5762843D429DC872EBA18",
"86A31E7131896CF01BA837945C2894385F369F24"]);
Protocol.Debugger.enable();
Protocol.Debugger.onScriptParsed(function(messageObject)
{
if (hashes.has(messageObject.params.hash))
InspectorTest.log(`Hash received: ${messageObject.params.hash}`);
else
InspectorTest.log(`[FAIL]: unknown hash ${messageObject.params.hash}`);
});
function longScript() {
var longScript = "var b = 1;";
for (var i = 0; i < 2024; ++i)
longScript += "++b;";
}
Protocol.Runtime.enable();
Protocol.Runtime.compileScript({ expression: "1", sourceURL: "foo1.js", persistScript: true });
Protocol.Runtime.compileScript({ expression: "239", sourceURL: "foo2.js", persistScript: true });
Protocol.Runtime.compileScript({ expression: "(" + longScript + ")()", sourceURL: "foo3.js", persistScript: true }).then(step2);
function step2()
{
(async function test() {
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
Protocol.Runtime.compileScript({
expression: "1", sourceURL: "foo1.js", persistScript: true});
let {params} = await Protocol.Debugger.onceScriptParsed();
InspectorTest.logMessage(params);
Protocol.Runtime.compileScript({
expression: "239", sourceURL: "foo2.js", persistScript: true});
({params} = await Protocol.Debugger.onceScriptParsed());
InspectorTest.logMessage(params);
var script = "var b = 1;";
for (var i = 0; i < 2024; ++i) {
script += "++b;";
}
Protocol.Runtime.compileScript({
expression: script, sourceURL: "foo3.js",
persistScript: true});
({params} = await Protocol.Debugger.onceScriptParsed());
InspectorTest.logMessage(params);
InspectorTest.completeTest();
}
})()