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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-runScript-async.js

Issue 2954093003: [DevTools] Migrate inspector-protocol/runtime tests to new harness (Closed)
Patch Set: fail: 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(`Tests that Runtime.comp ileScript and Runtime.runScript work with awaitPromise flag.`);
3
4 function dumpResult(result) {
5 if (result.error) {
6 result.error.code = 0;
7 testRunner.logObject(result.error);
8 return;
9 }
10 result = result.result;
11 if (result.exceptionDetails) {
12 result.exceptionDetails.exceptionId = 0;
13 result.exceptionDetails.exception.objectId = 0;
14 }
15 if (result.exceptionDetails && result.exceptionDetails.scriptId)
16 result.exceptionDetails.scriptId = 0;
17 if (result.exceptionDetails && result.exceptionDetails.stackTrace) {
18 for (var frame of result.exceptionDetails.stackTrace.callFrames)
19 frame.scriptId = 0;
20 }
21 if (result.result && result.result.objectId)
22 result.result.objectId = '[ObjectId]';
23 testRunner.logObject(result);
24 }
25
26 testRunner.runTestSuite([
27 async function testRunAndCompileWithoutAgentEnable() {
28 dumpResult(await dp.Runtime.compileScript({expression: '', sourceURL: '', persistScript: true}));
29 dumpResult(await dp.Runtime.runScript({scriptId: '1'}));
30 },
31
32 async function testSyntaxErrorInScript() {
33 await dp.Runtime.enable();
34 dumpResult(await dp.Runtime.compileScript({expression: '\n }', sourceURL: 'boo.js', persistScript: true}));
35 await dp.Runtime.disable();
36 },
37
38 async function testSyntaxErrorInEvalInScript() {
39 await dp.Runtime.enable();
40 var response = await dp.Runtime.compileScript({expression: '{\n eval(\'\\\ n}\')\n}', sourceURL: 'boo.js', persistScript: true});
41 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId} ));
42 await dp.Runtime.disable();
43 },
44
45 async function testRunNotCompiledScript() {
46 await dp.Runtime.enable();
47 dumpResult(await dp.Runtime.runScript({scriptId: '1'}));
48 await dp.Runtime.disable();
49 },
50
51 async function testRunCompiledScriptAfterAgentWasReenabled() {
52 await dp.Runtime.enable();
53 var response = await dp.Runtime.compileScript({expression: '{\n eval(\'\\\ n}\')\n}', sourceURL: 'boo.js', persistScript: true});
54 var scriptId = response.result.scriptId;
55 await dp.Runtime.disable();
56 dumpResult(await dp.Runtime.runScript({scriptId}));
57 await dp.Runtime.enable();
58 dumpResult(await dp.Runtime.runScript({scriptId}));
59 await dp.Runtime.disable();
60 },
61
62 async function testRunScriptWithPreview() {
63 await dp.Runtime.enable();
64 var response = await dp.Runtime.compileScript({expression: '({a:1})', sour ceURL: 'boo.js', persistScript: true});
65 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId, generatePreview: true}));
66 await dp.Runtime.disable();
67 },
68
69 async function testRunScriptReturnByValue() {
70 await dp.Runtime.enable();
71 var response = await dp.Runtime.compileScript({expression: '({a:1})', sour ceURL: 'boo.js', persistScript: true});
72 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId, returnByValue: true}));
73 await dp.Runtime.disable();
74 },
75
76 async function testAwaitNotPromise() {
77 await dp.Runtime.enable();
78 var response = await dp.Runtime.compileScript({expression: '({a:1})', sour ceURL: 'boo.js', persistScript: true});
79 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId, awaitPromise: true}));
80 await dp.Runtime.disable();
81 },
82
83 async function testAwaitResolvedPromise() {
84 await dp.Runtime.enable();
85 var response = await dp.Runtime.compileScript({expression: 'Promise.resolv e({a:1})', sourceURL: 'boo.js', persistScript: true});
86 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId, awaitPromise: true, returnByValue: true}));
87 await dp.Runtime.disable();
88 },
89
90 async function testAwaitRejectedPromise() {
91 await dp.Runtime.enable();
92 var response = await dp.Runtime.compileScript({expression: 'Promise.reject ({a:1})', sourceURL: 'boo.js', persistScript: true});
93 dumpResult(await dp.Runtime.runScript({scriptId: response.result.scriptId, awaitPromise: true, returnByValue: true}));
94 await dp.Runtime.disable();
95 }
96 ]);
97 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698