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
......
......@@ -8,7 +8,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 2ACD11425BF645075D5696189A7BA7EB4048D6F7
hash : 662C2191D614E753232391E558B6EC90C2F0E2F1
isLiveEdit : false
isModule : false
length : 42
......@@ -27,7 +27,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 0CD3C4132CE40E415D5696189A7BA7EB4048D6F7
hash : 362F9F016AAA39B904701571F19E8FA0B174F0B3
isLiveEdit : false
isModule : false
length : 52
......@@ -46,7 +46,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : true
hash : 0E35E860580550805D5681F7BCD47D855B794EB3
hash : 976FA8F0184B894A9B10AFE4AC94EC437EE4FB60
isLiveEdit : false
isModule : false
length : 43
......@@ -65,7 +65,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : true
hash : AD4760425BF645075D5681F7D1786BD4DA9A86A7
hash : 3F4F1CC20C664E61705CD011E025DD093676ED54
isLiveEdit : false
isModule : false
length : 46
......@@ -84,7 +84,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : false
hash : 3E60CE61913387795D5696189A7BA7EB4048B715
hash : 55928721655B662420FC9F66450A7C2C327C8C36
isLiveEdit : false
isModule : false
length : 50
......@@ -103,7 +103,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 3E60CE617215C621E8825B319A7BA7EB4048B715
hash : CF0E583119A280424958512525ECCFB3B4F7A262
isLiveEdit : false
isModule : false
length : 60
......@@ -122,7 +122,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : false
hash : F2A32D219EFACBF470C48663BCD47D85864D1A22
hash : D1FA51B286EA72144EC0E44681120344F2D2EBD5
isLiveEdit : false
isModule : false
length : 51
......@@ -141,7 +141,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : 46927EC1BFB78C355D5681F7D1786BD4216D5124
hash : 7ABA6300FC0D3908C0536EE2EFF60B48E36FFA35
isLiveEdit : false
isModule : false
length : 54
......@@ -160,7 +160,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 793E2411EDECF405E8825B31460F7CD9A656E096
hash : EB6DE473AF1788035E434F41ABC86140BD638644
isLiveEdit : false
isModule : false
length : 88
......@@ -179,7 +179,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : DED761235CC24EE21D0E9277CF599B5A292D8053
hash : 63710BD01F77B0F0C00E0662B45B782A5976A206
isLiveEdit : false
isModule : false
length : 89
......@@ -198,7 +198,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 9CF28A415BF64507692D5A84D1786BD4437C3511
hash : FC51669018C05471C8F46535240B9C77110E7291
isLiveEdit : false
isModule : false
length : 40
......@@ -217,7 +217,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : BEE49C625BF64507692D5A84D1786BD4437C3511
hash : FE0F41315BEF7930C8F465359F53D504110E7291
isLiveEdit : false
isModule : false
length : 41
......@@ -236,7 +236,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 1D33B330614150F8F7EB45184E245F542E304118
isLiveEdit : false
isModule : false
length : 18
......@@ -255,7 +255,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : D26251F019679C792E2B4EF437A20E96134D5C26
hash : 474CCF101B1996849E154ED20F854F368C793767
isLiveEdit : false
isModule : false
length : 96
......@@ -274,7 +274,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 814AEF635BF64507692D5A84BCD47D85C4031CD2
hash : DD0A3C60B97506161FA15D9419969A90DF33E2E0
isLiveEdit : false
isModule : false
length : 39
......@@ -293,7 +293,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A84A8DC8126872EBA18
hash : 1D33B330A774BD52F7EB45184E245F54C94FB815
isLiveEdit : false
isModule : false
length : 19
......@@ -312,7 +312,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 1D33B330EA93E221F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 20
......@@ -331,7 +331,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A84A8DC8126872EBA18
hash : 867981735982F829F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 21
......@@ -350,7 +350,7 @@ scriptParsed
endLine : 4
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 095D6881D29C0D76F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 22
......@@ -369,7 +369,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 2ACD11425BF645075D5696189A7BA7EB4048D6F7
hash : 662C2191D614E753232391E558B6EC90C2F0E2F1
isLiveEdit : false
isModule : false
length : 42
......@@ -388,7 +388,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 0CD3C4132CE40E415D5696189A7BA7EB4048D6F7
hash : 362F9F016AAA39B904701571F19E8FA0B174F0B3
isLiveEdit : false
isModule : false
length : 52
......@@ -407,7 +407,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : true
hash : 0E35E860580550805D5681F7BCD47D855B794EB3
hash : 976FA8F0184B894A9B10AFE4AC94EC437EE4FB60
isLiveEdit : false
isModule : false
length : 43
......@@ -426,7 +426,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : true
hash : AD4760425BF645075D5681F7D1786BD4DA9A86A7
hash : 3F4F1CC20C664E61705CD011E025DD093676ED54
isLiveEdit : false
isModule : false
length : 46
......@@ -445,7 +445,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : false
hash : 3E60CE61913387795D5696189A7BA7EB4048B715
hash : 55928721655B662420FC9F66450A7C2C327C8C36
isLiveEdit : false
isModule : false
length : 50
......@@ -464,7 +464,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 3E60CE617215C621E8825B319A7BA7EB4048B715
hash : CF0E583119A280424958512525ECCFB3B4F7A262
isLiveEdit : false
isModule : false
length : 60
......@@ -483,7 +483,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : false
hash : F2A32D219EFACBF470C48663BCD47D85864D1A22
hash : D1FA51B286EA72144EC0E44681120344F2D2EBD5
isLiveEdit : false
isModule : false
length : 51
......@@ -502,7 +502,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : 46927EC1BFB78C355D5681F7D1786BD4216D5124
hash : 7ABA6300FC0D3908C0536EE2EFF60B48E36FFA35
isLiveEdit : false
isModule : false
length : 54
......@@ -521,7 +521,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 793E2411EDECF405E8825B31460F7CD9A656E096
hash : EB6DE473AF1788035E434F41ABC86140BD638644
isLiveEdit : false
isModule : false
length : 88
......@@ -540,7 +540,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : DED761235CC24EE21D0E9277CF599B5A292D8053
hash : 63710BD01F77B0F0C00E0662B45B782A5976A206
isLiveEdit : false
isModule : false
length : 89
......@@ -559,7 +559,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : 9CF28A415BF64507692D5A84D1786BD4437C3511
hash : FC51669018C05471C8F46535240B9C77110E7291
isLiveEdit : false
isModule : false
length : 40
......@@ -578,7 +578,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : BEE49C625BF64507692D5A84D1786BD4437C3511
hash : FE0F41315BEF7930C8F465359F53D504110E7291
isLiveEdit : false
isModule : false
length : 41
......@@ -597,7 +597,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 1D33B330614150F8F7EB45184E245F542E304118
isLiveEdit : false
isModule : false
length : 18
......@@ -616,7 +616,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : D26251F019679C792E2B4EF437A20E96134D5C26
hash : 474CCF101B1996849E154ED20F854F368C793767
isLiveEdit : false
isModule : false
length : 96
......@@ -635,7 +635,7 @@ scriptParsed
endLine : 0
executionContextId : <executionContextId>
hasSourceURL : true
hash : 814AEF635BF64507692D5A84BCD47D85C4031CD2
hash : DD0A3C60B97506161FA15D9419969A90DF33E2E0
isLiveEdit : false
isModule : false
length : 39
......@@ -665,7 +665,7 @@ scriptFailedToParse
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : true
hash : C0C37C619263496792D5CFE7CA6F2911028287A6
hash : BB13EE1015533BA2FF7F72464D9CDD374BABDA67
isModule : false
length : 56
scriptId : <scriptId>
......@@ -683,7 +683,7 @@ scriptParsed
endLine : 1
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A84A8DC8126872EBA18
hash : 1D33B330A774BD52F7EB45184E245F54C94FB815
isLiveEdit : false
isModule : false
length : 19
......@@ -702,7 +702,7 @@ scriptParsed
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 1D33B330EA93E221F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 20
......@@ -721,7 +721,7 @@ scriptParsed
endLine : 3
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A84A8DC8126872EBA18
hash : 867981735982F829F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 21
......@@ -740,7 +740,7 @@ scriptParsed
endLine : 4
executionContextId : <executionContextId>
hasSourceURL : false
hash : 9CF28A415BF64507692D5A8443D429DC872EBA18
hash : 095D6881D29C0D76F7EB45184E245F5479702083
isLiveEdit : false
isModule : false
length : 22
......
......@@ -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