Commit 86d512c8 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] calculate correct script hash

We used to calculate hash in completely incorrect way. We use each
forth character to calculate hash but we should use each one.

R=dgozman@chromium.org

Bug: v8:7426
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Iaaa317bbf3b3ef71632735dfd069db450283b6f4
Reviewed-on: https://chromium-review.googlesource.com/909586
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51191}
parent 199a3341
......@@ -43,7 +43,7 @@ String16 calculateHash(const String16& str) {
const uint32_t* data = nullptr;
size_t sizeInBytes = sizeof(UChar) * str.length();
data = reinterpret_cast<const uint32_t*>(str.characters16());
for (size_t i = 0; i < sizeInBytes / 4; i += 4) {
for (size_t i = 0; i < sizeInBytes / 4; ++i) {
#if V8_TARGET_LITTLE_ENDIAN
uint32_t v = data[i];
#else
......
......@@ -8,7 +8,7 @@ Running test: testLoadedModulesOnDebuggerEnable
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : F8E59942466284E2766FD161CA6FFD024048A807
hash : DD672B308FB57B18CCEBFA236C372DBBC001DAD2
isLiveEdit : false
isModule : true
length : 39
......@@ -28,7 +28,7 @@ Running test: testScriptEventsWhenDebuggerIsEnabled
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : F8E59942466284E2766FD161CA6FFD024048A807
hash : DD672B308FB57B18CCEBFA236C372DBBC001DAD2
isLiveEdit : false
isModule : true
length : 39
......
......@@ -6,7 +6,7 @@ getPossibleBreakpoints should not crash during lazy compilation (crbug.com/71533
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : true
hash : FA2A959297747012766FE9C5006E7F522D88FA72
hash : 720BC4212F9AA3E834D156055BEFEDC32027C816
isLiveEdit : false
isModule : false
length : 52
......
......@@ -7,7 +7,7 @@ Runtime.evaluate with valid expression
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 9D04F7335D1661503EAB9AF3EACAF92020803F34
hash : A933D880D35072516A27D817C0079F01FEE46E23
isLiveEdit : false
isModule : false
length : 29
......@@ -26,7 +26,7 @@ Runtime.evaluate with syntax error
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 9BCA34A10E5386925E74C1716C857BEB02821E15
hash : 81077F73E5B26710D5CE891275FA68AC12493B57
isModule : false
length : 39
scriptId : <scriptId>
......@@ -44,7 +44,7 @@ Runtime.callFunctionOn with valid functionDeclaration
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9D04CEA1B54DF92A01A0498543D429DC872EBA18
hash : 53BA9611A1E9ABE81E93AF82DEC875F94048A807
isLiveEdit : false
isModule : false
length : 18
......@@ -81,7 +81,7 @@ Runtime.compileScript with valid expression
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9D04F733E4E4F1BA4CB5762843D429DC872EBA18
hash : 9D04F7336B76D25A4CB5762843D429DC872EBA18
isLiveEdit : false
isModule : false
length : 4
......@@ -119,7 +119,7 @@ Runtime.evaluate compiled script with stack trace
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : A2185340E4E4F1BA4CB5762843D429DC872EBA18
hash : A2185340102B6713AB58F5467452EC0C872EBA18
isLiveEdit : false
isModule : false
length : 8
......@@ -137,7 +137,7 @@ Runtime.evaluate compiled script with stack trace
endLine : 4
executionContextId : <executionContextId>
hasSourceURL : true
hash : 6AF4ED72C355E471C4E94D74464A25541932A242
hash : 31052EF18E11A850DBC812A6154A27BA713D3521
isLiveEdit : false
isModule : false
length : 86
......@@ -166,7 +166,7 @@ Runtime.evaluate compiled script with stack trace
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9D04F733E4E4F1BA4CB5762843D429DC872EBA18
hash : 9D04F7336B76D25A4CB5762843D429DC872EBA18
isLiveEdit : false
isModule : false
length : 4
......@@ -196,7 +196,7 @@ Runtime.evaluate compile script error with stack trace
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : A218534034AA14704CB5762843D429DC872EBA18
hash : 55C8AE40102B6713AB58F546879BAE951E6BF325
isLiveEdit : false
isModule : false
length : 12
......@@ -214,7 +214,7 @@ Runtime.evaluate compile script error with stack trace
endLine : 4
executionContextId : <executionContextId>
hasSourceURL : true
hash : 5FD5C8C38F2D44588A4078148B0BC5635152B0C0
hash : 578C87106744016A01ADEA516DC739379190F4E2
isLiveEdit : false
isModule : false
length : 98
......
......@@ -34,7 +34,7 @@ Tests scripts hasing
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 885818413D7FC3E2220B3E367FF57CB1D1572095
hash : 0449F3A28D4C32C1EC3696332EAD65644BDE59A7
isLiveEdit : false
isModule : false
length : 8106
......
Checks hash in Debugger.scriptParsed event
1
2
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1 ;
2 ;
PASS
1;
2;
PASS
// Copyright 2018 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 hash in Debugger.scriptParsed event');
(async function main() {
Protocol.Debugger.enable();
const tests = [{firstScript: '1', secondScript: '2'}];
for (let length = 1; length <= 10; ++length) {
for (let differentChar = 0; differentChar < length; ++differentChar) {
const firstScript = ' '.repeat(differentChar) + '1' +
' '.repeat(length - differentChar - 1) + ';';
const secondScript = ' '.repeat(differentChar) + '2' +
' '.repeat(length - differentChar - 1) + ';';
tests.push({firstScript, secondScript});
}
}
for (const {firstScript, secondScript} of tests) {
InspectorTest.log(firstScript);
const firstScriptParsed = Protocol.Debugger.onceScriptParsed();
Protocol.Runtime.evaluate({expression: firstScript});
const hash1 = (await firstScriptParsed).params.hash;
InspectorTest.log(secondScript);
const secondScriptParsed = Protocol.Debugger.onceScriptParsed();
Protocol.Runtime.evaluate({expression: secondScript});
const hash2 = (await secondScriptParsed).params.hash;
InspectorTest.log(hash1 === hash2 ? 'Error: the same hash!' : 'PASS');
}
InspectorTest.completeTest();
})();
......@@ -6,7 +6,7 @@ Checks basic ES6 modules support.
endLine : 5
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9C014F7249BAFA12B91017817AD15091D01A9155
hash : E885A593519C4CD31BC243D5D06DCB961A1C69B5
isLiveEdit : false
isModule : true
length : 83
......@@ -24,7 +24,7 @@ Checks basic ES6 modules support.
endLine : 5
executionContextId : <executionContextId>
hasSourceURL : false
hash : 443A2FA24A6112E6B9101781E6A19B56BDC396D4
hash : EFD8445134EBF926917EAE6072964574AB6D6C60
isLiveEdit : false
isModule : true
length : 84
......@@ -42,7 +42,7 @@ Checks basic ES6 modules support.
endLine : 8
executionContextId : <executionContextId>
hasSourceURL : false
hash : 54D834614FBF9B389082DAE06CD3EFC499BEBF13
hash : B454ADE26B54DA4057C498A205C459099654AC47
isLiveEdit : false
isModule : true
length : 191
......
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