Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / crypto / digest-failures.html
index 1162e1c..a9b50a0 100644 (file)
@@ -13,27 +13,37 @@ description("Tests incorrect calls to crypto.subtle.digest()");
 
 jsTestIsAsync = true;
 
-// Pass invalid data to digest()
-shouldThrow("crypto.subtle.digest({name: 'sha-1'})");
-shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)");
-shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)");
+Promise.resolve(null).then(function(result) {
+    // Called with too few parameters.
+    return crypto.subtle.digest({name: 'sha-1'});
+}).then(failAndFinishJSTest, function(result) {
+    logError(result);
 
-// Pass invalid algorithmIdentifiers to digest()
-data = new Uint8Array([0]);
-shouldThrow("crypto.subtle.digest(null, data)");
+    // "null" is not a valid data argument.
+    return crypto.subtle.digest({name: 'sha-1'}, null);
+}).then(failAndFinishJSTest, function(result) {
+    logError(result);
+
+    // 10 is not a valid data argument.
+    return crypto.subtle.digest({name: 'sha-1'}, 10);
+}).then(failAndFinishJSTest, function(result) {
+    logError(result);
+
+    // null is not a valid algorithm argument.
+    data = new Uint8Array([0]);
+    return crypto.subtle.digest(null, data);
+}).then(failAndFinishJSTest, function(result) {
+    logError(result);
 
-Promise.resolve(null).then(function(result) {
     // "sha" is not a recognized algorithm name
     return crypto.subtle.digest({name: 'sha'}, data);
 }).then(failAndFinishJSTest, function(result) {
-    error = result;
-    shouldBeNull("error");
+    logError(result);
 
     // Algorithm lacks a name.
     return crypto.subtle.digest({}, data);
 }).then(failAndFinishJSTest, function(result) {
-    error = result;
-    shouldBeNull("error");
+    logError(result);
   
 }).then(finishJSTest, failAndFinishJSTest);