forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DevTools] Migrate inspector-protocol/runtime tests to new harness
BUG=734762 Review-Url: https://codereview.chromium.org/2954093003 Cr-Commit-Position: refs/heads/master@{#482493}
- Loading branch information
Showing
74 changed files
with
1,118 additions
and
1,842 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 0 additions & 143 deletions
143
third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise.html
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
(async function(testRunner) { | ||
let {page, session, dp} = await testRunner.startBlank('Tests that Runtime.awaitPromise works.'); | ||
|
||
function dumpResult(result) { | ||
if (result.exceptionDetails) { | ||
if (result.exceptionDetails.stackTrace && result.exceptionDetails.stackTrace.parent) { | ||
for (var frame of result.exceptionDetails.stackTrace.parent.callFrames) { | ||
frame.scriptId = 0; | ||
frame.url = ''; | ||
} | ||
} | ||
result.exceptionDetails.exceptionId = 0; | ||
if (result.exceptionDetails.exception) | ||
result.exceptionDetails.exception.objectId = 0; | ||
} | ||
testRunner.logObject(result); | ||
} | ||
|
||
await session.evaluate(` | ||
var resolveCallback; | ||
var rejectCallback; | ||
function createPromise() { | ||
return new Promise((resolve, reject) => { resolveCallback = resolve; rejectCallback = reject }); | ||
} | ||
function resolvePromise() { | ||
resolveCallback(239); | ||
resolveCallback = undefined; | ||
rejectCallback = undefined; | ||
} | ||
function rejectPromise() { | ||
rejectCallback(239); | ||
resolveCallback = undefined; | ||
rejectCallback = undefined; | ||
} | ||
function runGC() { | ||
if (window.gc) | ||
window.gc(); | ||
} | ||
`); | ||
|
||
await dp.Debugger.enable(); | ||
await dp.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); | ||
|
||
await testRunner.runTestSuite([ | ||
async function testResolvedPromise() { | ||
var result = await dp.Runtime.evaluate({ expression: 'Promise.resolve(239)'}); | ||
result = await dp.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: false, generatePreview: true }); | ||
dumpResult(result.result); | ||
}, | ||
|
||
async function testRejectedPromise() { | ||
var result = await dp.Runtime.evaluate({ expression: 'Promise.reject({ a : 1 })'}); | ||
result = await dp.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }); | ||
dumpResult(result.result); | ||
}, | ||
|
||
async function testRejectedPromiseWithStack() { | ||
var result = await dp.Runtime.evaluate({ expression: 'createPromise()'}); | ||
var promise = dp.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId }); | ||
dp.Runtime.evaluate({ expression: 'rejectPromise()' }); | ||
result = await promise; | ||
dumpResult(result.result); | ||
}, | ||
|
||
async function testPendingPromise() { | ||
var result = await dp.Runtime.evaluate({ expression: 'createPromise()'}); | ||
var promise = dp.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId }); | ||
dp.Runtime.evaluate({ expression: 'resolvePromise()' }); | ||
result = await promise; | ||
dumpResult(result.result); | ||
}, | ||
|
||
async function testResolvedWithoutArgsPromise() { | ||
var result = await dp.Runtime.evaluate({ expression: 'Promise.resolve()'}); | ||
result = await dp.Runtime.awaitPromise({ promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }); | ||
dumpResult(result.result); | ||
}, | ||
|
||
async function testGarbageCollectedPromise() { | ||
var result = await dp.Runtime.evaluate({ expression: 'new Promise(() => undefined)'}); | ||
var objectId = result.result.result.objectId; | ||
var promise = dp.Runtime.awaitPromise({ promiseObjectId: objectId }); | ||
dp.Runtime.releaseObject({ objectId: objectId}).then(() => dp.Runtime.evaluate({ expression: 'runGC()' })); | ||
result = await promise; | ||
testRunner.logObject(result.error); | ||
} | ||
]); | ||
}) |
Oops, something went wrong.