Title: [208759] trunk/LayoutTests
Revision
208759
Author
[email protected]
Date
2016-11-15 14:50:35 -0800 (Tue, 15 Nov 2016)

Log Message

js-test-pre.js::shouldReject doesn't need _rejectCallback and _resolveCallback
https://bugs.webkit.org/show_bug.cgi?id=164758

Reviewed by Youenn Fablet.

Since the function returns a promise, it doesn't need _rejectCallback and _resolveCallback.

* crypto/subtle/generate-key-malformed-parameters.html:
* crypto/subtle/rsa-generate-key-malformed-parameters.html:
* crypto/workers/subtle/resources/rsa-generate-key.js:
* crypto/workers/subtle/rsa-generate-key-expected.txt:
* resources/js-test-pre.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208758 => 208759)


--- trunk/LayoutTests/ChangeLog	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/ChangeLog	2016-11-15 22:50:35 UTC (rev 208759)
@@ -1,3 +1,18 @@
+2016-11-15  Jiewen Tan  <[email protected]>
+
+        js-test-pre.js::shouldReject doesn't need _rejectCallback and _resolveCallback
+        https://bugs.webkit.org/show_bug.cgi?id=164758
+
+        Reviewed by Youenn Fablet.
+
+        Since the function returns a promise, it doesn't need _rejectCallback and _resolveCallback.
+
+        * crypto/subtle/generate-key-malformed-parameters.html:
+        * crypto/subtle/rsa-generate-key-malformed-parameters.html:
+        * crypto/workers/subtle/resources/rsa-generate-key.js:
+        * crypto/workers/subtle/rsa-generate-key-expected.txt:
+        * resources/js-test-pre.js:
+
 2016-11-15  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: inspector/worker/debugger-pause.html fails on WebKit1

Modified: trunk/LayoutTests/crypto/subtle/generate-key-malformed-parameters.html (208758 => 208759)


--- trunk/LayoutTests/crypto/subtle/generate-key-malformed-parameters.html	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/crypto/subtle/generate-key-malformed-parameters.html	2016-11-15 22:50:35 UTC (rev 208759)
@@ -59,7 +59,7 @@
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, ["foo"])');
 // Syntax error.
 shouldReject('crypto.subtle.generateKey({name: "AES-CBC", length: 128}, extractable, [ ])');
-shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01])}, extractable, [ ])', finishJSTest);
+shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01])}, extractable, [ ])').then(finishJSTest);
 </script>
 
 <script src=""

Modified: trunk/LayoutTests/crypto/subtle/rsa-generate-key-malformed-parameters.html (208758 => 208759)


--- trunk/LayoutTests/crypto/subtle/rsa-generate-key-malformed-parameters.html	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/crypto/subtle/rsa-generate-key-malformed-parameters.html	2016-11-15 22:50:35 UTC (rev 208759)
@@ -50,7 +50,7 @@
 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveKey"])');
 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveBits"])');
 // modulusLength = 0
-shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])', finishJSTest);
+shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])').then(finishJSTest);
 </script>
 
 <script src=""

Modified: trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-key.js (208758 => 208759)


--- trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-key.js	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsa-generate-key.js	2016-11-15 22:50:35 UTC (rev 208759)
@@ -7,19 +7,11 @@
 var extractable = true;
 var publicExponent = new Uint8Array([0x01, 0x00, 0x01]);
 
-var count = 0;
-function finishTest()
-{
-    count = count + 1;
-    if (count == 2)
-        finishJSTest();
-}
-
 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign"])');
-shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])', finishTest);
-
-debug("Generating a key...");
-crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: 'sha-1'}, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])').then(function() {
+    debug("Generating a key...");
+    return crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: 'sha-1'}, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]);
+}).then(function(result) {
     keyPair = result;
     shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
     shouldBe("keyPair.publicKey.type", "'public'");
@@ -37,5 +29,5 @@
     shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'");
     shouldBe("keyPair.privateKey.usages", "['decrypt', 'unwrapKey']");
 
-    finishTest();
+    finishJSTest();
 });

Modified: trunk/LayoutTests/crypto/workers/subtle/rsa-generate-key-expected.txt (208758 => 208759)


--- trunk/LayoutTests/crypto/workers/subtle/rsa-generate-key-expected.txt	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/crypto/workers/subtle/rsa-generate-key-expected.txt	2016-11-15 22:50:35 UTC (rev 208759)
@@ -4,9 +4,9 @@
 
 
 Starting worker: resources/rsa-generate-key.js
-[Worker] Generating a key...
 PASS [Worker] crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS [Worker] crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+[Worker] Generating a key...
 PASS [Worker] keyPair.toString() is '[object CryptoKeyPair]'
 PASS [Worker] keyPair.publicKey.type is 'public'
 PASS [Worker] keyPair.publicKey.extractable is true

Modified: trunk/LayoutTests/resources/js-test-pre.js (208758 => 208759)


--- trunk/LayoutTests/resources/js-test-pre.js	2016-11-15 22:48:01 UTC (rev 208758)
+++ trunk/LayoutTests/resources/js-test-pre.js	2016-11-15 22:50:35 UTC (rev 208759)
@@ -633,7 +633,7 @@
         testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
 }
 
-function shouldReject(_a, _rejectCallback, _resolveCallback, _message)
+function shouldReject(_a, _message)
 {
     var _exception;
     var _av;
@@ -646,12 +646,8 @@
 
      return _av.then(function(result) {
         testFailed((_message ? _message : _a) + " should reject promise. Resolved with " + result + ".");
-        if (typeof _resolveCallback == "function")
-            _resolveCallback();
     }, function(error) {
         testPassed((_message ? _message : _a) + " rejected promise  with " + error + ".");
-        if (typeof _rejectCallback == "function")
-            _rejectCallback();
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to