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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-promise-then.html

Issue 2185233002: [DevTools] Added Runtime.awaitPromise protocol method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-promise-then.html
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-promise-then.html b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-promise-then.html
new file mode 100644
index 0000000000000000000000000000000000000000..98198c4d71429a7cd7c8647a19d74997fcfabff7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-promise-then.html
@@ -0,0 +1,92 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script>
+
+var callback;
+function createPromise()
+{
+ return new Promise(fulfill => callback = fulfill);
+}
+
+function fulfillPromise()
+{
+ callback(239);
+ callback = undefined;
+}
+
+function runGC()
+{
+ if (window.gc)
+ window.gc();
+}
+
+function test()
+{
+ InspectorTest.runTestSuite([
+ function testResolvedPromise(next)
+ {
+ InspectorTest.runtimeEvaluatePromise("Promise.resolve(239)")
+ .then((result) => InspectorTest.runtimePromiseThenPromise(result.result.result.objectId, /* returnByValue */ false, /* generatePreview */ true))
+ .then((result) => InspectorTest.logObject(result.result))
+ .then(() => next());
+ },
+
+ function testRejectedPromise(next)
+ {
+ InspectorTest.runtimeEvaluatePromise("Promise.reject({ a : 1 })")
+ .then((result) => InspectorTest.runtimePromiseThenPromise(result.result.result.objectId, /* returnByValue */ true, /* generatePreview */ false))
+ .then((result) => InspectorTest.logObject(result.result))
+ .then(() => next());
+ },
+
+ function testPengingPromise(next)
dgozman 2016/07/28 00:07:56 typo: pending
kozy 2016/07/28 22:54:09 Done.
+ {
+ InspectorTest.runtimeEvaluatePromise("createPromise()")
+ .then((result) => scheduleFulfillAndPromiseThen(result))
+ .then((result) => InspectorTest.logObject(result.result))
+ .then(() => next());
+
+ function scheduleFulfillAndPromiseThen(result)
+ {
+ setTimeout(() => InspectorTest.runtimeEvaluatePromise("fulfillPromise()"), 0);
+ return InspectorTest.runtimePromiseThenPromise(result.result.result.objectId);
+ }
+ },
+
+ function testResolvedWithoutArgsPromise(next)
+ {
+ InspectorTest.runtimeEvaluatePromise("Promise.resolve()")
+ .then((result) => InspectorTest.runtimePromiseThenPromise(result.result.result.objectId))
+ .then((result) => InspectorTest.logObject(result.result))
+ .then(() => next());
+ },
+
+ function testGarbageCollectedPromise(next)
+ {
+ InspectorTest.runtimeEvaluatePromise("new Promise(() => undefined)")
+ .then((result) => scheduleGCAndPromiseThen(result))
+ .then((result) => InspectorTest.logObject(result.error))
+ .then(() => next());
+
+ function scheduleGCAndPromiseThen(result)
+ {
+ var objectId = result.result.result.objectId;
+ setTimeout(gcPromise.bind(null, objectId), 0);
dgozman 2016/07/28 00:07:56 Let's try without setTimeout.
kozy 2016/07/28 22:54:09 Done.
+ return InspectorTest.runtimePromiseThenPromise(objectId);
+ }
+
+ function gcPromise(objectId)
+ {
+ InspectorTest.runtimeReleaseObjectPromise(objectId)
+ .then(() => InspectorTest.runtimeEvaluatePromise("runGC()"));
+ }
+ }
+ ]);
+}
+</script>
+</head>
+<body onLoad="runTest();">
+Tests that Runtime.promiseThen works.
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698