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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.js b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.js
new file mode 100644
index 0000000000000000000000000000000000000000..31b4f619c7b1e28ad93e0fb4acfa78489ec9d67f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.js
@@ -0,0 +1,46 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startBlank('');
+
+ function logEqualsCheck(actual, expected) {
+ if (actual == expected) {
+ testRunner.log('PASS, result value: ' + actual);
+ } else {
+ testRunner.log('FAIL, actual value: ' + actual + ', expected: ' + expected);
+ }
+ }
+
+ await session.evaluate(
+ `function TestExpression(a, b) {
+ return a + b;
+ }`);
+
+ await dp.Debugger.enable();
+
+ var response = await dp.Runtime.evaluate({expression: 'TestExpression(2, 4)' });
+ testRunner.log('Function evaluate: ' + JSON.stringify(response.result.result));
+ logEqualsCheck(response.result.result.value, 6);
+
+ var functionObjectId = (await dp.Runtime.evaluate({expression: 'TestExpression' })).result.result.objectId;
+ var result = (await dp.Runtime.getProperties({ objectId: functionObjectId})).result;
+ var scriptId;
+ for (var prop of result.internalProperties) {
+ if (prop.name === '[[FunctionLocation]]')
+ scriptId = prop.value.value.scriptId;
+ }
+
+ var originalText = (await dp.Debugger.getScriptSource({scriptId})).result.scriptSource;
+ var patched = originalText.replace('a + b', 'a * b');
+ await dp.Debugger.setScriptSource({scriptId, scriptSource: patched});
+
+ var response = await dp.Runtime.evaluate({expression: 'TestExpression(2, 4)' });
+ testRunner.log('Function evaluate: ' + JSON.stringify(response.result.result));
+ logEqualsCheck(response.result.result.value, 8);
+
+ patched = originalText.replace('a + b', 'a # b');
+ var exceptionDetails = (await dp.Debugger.setScriptSource({scriptId, scriptSource: patched})).result.exceptionDetails;
+ testRunner.log(`Has error reported: ${!!exceptionDetails ? 'PASS' : 'FAIL'}`, );
+ testRunner.log(`Reported error is a compile error: ${!!exceptionDetails ? 'PASS' : 'FAIL'}`, );
+ if (exceptionDetails)
+ logEqualsCheck(exceptionDetails.lineNumber, 1);
+ testRunner.completeTest();
+})

Powered by Google App Engine
This is Rietveld 408576698