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

Unified Diff: LayoutTests/crypto/resources/common.js

Issue 141413003: [webcrypto] Match the error handling defined by the spec. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/resources/common.js
diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js
index 0edef40925ef94e90c50bb673e20d782aca9a774..d2335ab63fe3ef8b8893551e35c415ed5fd4b902 100644
--- a/LayoutTests/crypto/resources/common.js
+++ b/LayoutTests/crypto/resources/common.js
@@ -87,3 +87,62 @@ function failAndFinishJSTest(error)
debug(error);
finishJSTest();
}
+
+numOutstandingTasks = 0;
+
+function addTask(promise)
+{
+ numOutstandingTasks++;
+
+ function taskFinished()
+ {
+ numOutstandingTasks--;
+ completeTestWhenAllTasksDone();
+ }
+
+ promise.then(taskFinished, taskFinished);
+}
+
+function completeTestWhenAllTasksDone()
+{
+ if (numOutstandingTasks == 0) {
+ finishJSTest();
+ }
+}
+
+function shouldRejectPromiseWithNull(code)
+{
+ var promise = eval(code);
+
+ function acceptCallback(result)
+ {
+ debug("FAIL: '" + code + "' accepted with " + result + " but should have been rejected");
+ }
+
+ function rejectCallback(result)
+ {
+ if (result == null)
+ debug("PASS: '" + code + "' rejected with null");
+ else
+ debug("FAIL: '" + code + "' rejected with " + result + " but was expecting null");
+ }
+
+ addTask(promise.then(acceptCallback, rejectCallback));
+}
+
+function shouldAcceptPromise(code)
+{
+ var promise = eval(code);
+
+ function acceptCallback(result)
+ {
+ debug("PASS: '" + code + "' accepted with " + result);
+ }
+
+ function rejectCallback(result)
+ {
+ debug("FAIL: '" + code + "' rejected with " + result);
+ }
+
+ addTask(promise.then(acceptCallback, rejectCallback));
+}
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698