Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.js

Issue 2968523003: [DevTools] Migrate inspector-protocol/debugger tests to new harness (Closed)
Patch Set: all tests Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startBlank('');
3
4 function logEqualsCheck(actual, expected) {
5 if (actual == expected) {
6 testRunner.log('PASS, result value: ' + actual);
7 } else {
8 testRunner.log('FAIL, actual value: ' + actual + ', expected: ' + expected );
9 }
10 }
11
12 await session.evaluate(
13 `function TestExpression(a, b) {
14 return a + b;
15 }`);
16
17 await dp.Debugger.enable();
18
19 var response = await dp.Runtime.evaluate({expression: 'TestExpression(2, 4)' } );
20 testRunner.log('Function evaluate: ' + JSON.stringify(response.result.result)) ;
21 logEqualsCheck(response.result.result.value, 6);
22
23 var functionObjectId = (await dp.Runtime.evaluate({expression: 'TestExpression ' })).result.result.objectId;
24 var result = (await dp.Runtime.getProperties({ objectId: functionObjectId})).r esult;
25 var scriptId;
26 for (var prop of result.internalProperties) {
27 if (prop.name === '[[FunctionLocation]]')
28 scriptId = prop.value.value.scriptId;
29 }
30
31 var originalText = (await dp.Debugger.getScriptSource({scriptId})).result.scri ptSource;
32 var patched = originalText.replace('a + b', 'a * b');
33 await dp.Debugger.setScriptSource({scriptId, scriptSource: patched});
34
35 var response = await dp.Runtime.evaluate({expression: 'TestExpression(2, 4)' } );
36 testRunner.log('Function evaluate: ' + JSON.stringify(response.result.result)) ;
37 logEqualsCheck(response.result.result.value, 8);
38
39 patched = originalText.replace('a + b', 'a # b');
40 var exceptionDetails = (await dp.Debugger.setScriptSource({scriptId, scriptSou rce: patched})).result.exceptionDetails;
41 testRunner.log(`Has error reported: ${!!exceptionDetails ? 'PASS' : 'FAIL'}`, );
42 testRunner.log(`Reported error is a compile error: ${!!exceptionDetails ? 'PAS S' : 'FAIL'}`, );
43 if (exceptionDetails)
44 logEqualsCheck(exceptionDetails.lineNumber, 1);
45 testRunner.completeTest();
46 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698