OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/modules/v8/serialization/V8ScriptValueSerializerForModules.h" | 5 #include "bindings/modules/v8/serialization/V8ScriptValueSerializerForModules.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ToV8.h" | 8 #include "bindings/core/v8/ToV8.h" |
9 #include "bindings/core/v8/V8ArrayBuffer.h" | 9 #include "bindings/core/v8/V8ArrayBuffer.h" |
10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 }))) | 287 }))) |
288 ->bindToV8Function()); | 288 ->bindToV8Function()); |
289 return result->result(); | 289 return result->result(); |
290 } | 290 } |
291 | 291 |
292 template <typename T, typename PMF, typename... Args> | 292 template <typename T, typename PMF, typename... Args> |
293 T subtleCryptoSync(ScriptState* scriptState, PMF func, Args&&... args) { | 293 T subtleCryptoSync(ScriptState* scriptState, PMF func, Args&&... args) { |
294 T result; | 294 T result; |
295 (Platform::current()->crypto()->*func)( | 295 (Platform::current()->crypto()->*func)( |
296 std::forward<Args>(args)..., | 296 std::forward<Args>(args)..., |
297 toWebCryptoResult(scriptState, WTF::bind( | 297 toWebCryptoResult(scriptState, |
298 [](T* out, T result) { | 298 WTF::bind( |
299 *out = result; | 299 [](T* out, T result) { |
300 testing::exitRunLoop(); | 300 *out = result; |
301 }, | 301 testing::exitRunLoop(); |
302 WTF::unretained(&result)))); | 302 }, |
| 303 WTF::unretained(&result)))); |
303 testing::enterRunLoop(); | 304 testing::enterRunLoop(); |
304 return result; | 305 return result; |
305 } | 306 } |
306 | 307 |
307 CryptoKey* syncGenerateKey(ScriptState* scriptState, | 308 CryptoKey* syncGenerateKey(ScriptState* scriptState, |
308 const WebCryptoAlgorithm& algorithm, | 309 const WebCryptoAlgorithm& algorithm, |
309 bool extractable, | 310 bool extractable, |
310 WebCryptoKeyUsageMask usages) { | 311 WebCryptoKeyUsageMask usages) { |
311 return subtleCryptoSync<CryptoKey*>(scriptState, &WebCrypto::generateKey, | 312 return subtleCryptoSync<CryptoKey*>(scriptState, &WebCrypto::generateKey, |
312 algorithm, extractable, usages); | 313 algorithm, extractable, usages); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 0xb0, 0xf5, 0x62, 0x09, 0xab, 0x93, 0x8c, 0x21, 0xaf, | 844 0xb0, 0xf5, 0x62, 0x09, 0xab, 0x93, 0x8c, 0x21, 0xaf, |
844 0xb7, 0x66, 0xa9, 0xfc, 0xd2, 0xaa, 0xd8, 0xd4, 0x79, | 845 0xb7, 0x66, 0xa9, 0xfc, 0xd2, 0xaa, 0xd8, 0xd4, 0x79, |
845 0xf2, 0x55, 0x3a, 0xef, 0x46, 0x03, 0xec, 0x64, 0x2f, | 846 0xf2, 0x55, 0x3a, 0xef, 0x46, 0x03, 0xec, 0x64, 0x2f, |
846 0x68, 0xea, 0x9f, 0x9d, 0x1d, 0xd2, 0x42, 0xd0, 0x13, | 847 0x68, 0xea, 0x9f, 0x9d, 0x1d, 0xd2, 0x42, 0xd0, 0x13, |
847 0x6c, 0xe0, 0xe1, 0xed, 0x9c, 0x59, 0x46, 0x85, 0xaf, | 848 0x6c, 0xe0, 0xe1, 0xed, 0x9c, 0x59, 0x46, 0x85, 0xaf, |
848 0x41, 0xc4, 0x6a, 0x2d, 0x06, 0x7a})) | 849 0x41, 0xc4, 0x6a, 0x2d, 0x06, 0x7a})) |
849 .deserialize() | 850 .deserialize() |
850 ->IsNull()); | 851 ->IsNull()); |
851 | 852 |
852 // Input ends before end of declared public exponent size. | 853 // Input ends before end of declared public exponent size. |
853 EXPECT_TRUE( | 854 EXPECT_TRUE(V8ScriptValueDeserializerForModules( |
854 V8ScriptValueDeserializerForModules( | 855 scriptState, |
855 scriptState, serializedValue({0xff, 0x09, 0x3f, 0x00, 0x4b, 0x04, | 856 serializedValue({0xff, 0x09, 0x3f, 0x00, 0x4b, 0x04, 0x0d, |
856 0x0d, 0x01, 0x80, 0x08, 0x03, 0x01})) | 857 0x01, 0x80, 0x08, 0x03, 0x01})) |
857 .deserialize() | 858 .deserialize() |
858 ->IsNull()); | 859 ->IsNull()); |
859 } | 860 } |
860 | 861 |
861 TEST(V8ScriptValueSerializerForModulesTest, RoundTripDOMFileSystem) { | 862 TEST(V8ScriptValueSerializerForModulesTest, RoundTripDOMFileSystem) { |
862 V8TestingScope scope; | 863 V8TestingScope scope; |
863 | 864 |
864 DOMFileSystem* fs = DOMFileSystem::create( | 865 DOMFileSystem* fs = DOMFileSystem::create( |
865 scope.getExecutionContext(), "http_example.com_0:Persistent", | 866 scope.getExecutionContext(), "http_example.com_0:Persistent", |
866 FileSystemTypePersistent, | 867 FileSystemTypePersistent, |
867 KURL(ParsedURLString, "filesystem:http://example.com/persistent/")); | 868 KURL(ParsedURLString, "filesystem:http://example.com/persistent/")); |
868 // At time of writing, this can only happen for filesystems from PPAPI. | 869 // At time of writing, this can only happen for filesystems from PPAPI. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x69, | 940 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x69, |
940 0x73, 0x74, 0x65, 0x6e, 0x74, 0x2f | 941 0x73, 0x74, 0x65, 0x6e, 0x74, 0x2f |
941 | 942 |
942 })) | 943 })) |
943 .deserialize() | 944 .deserialize() |
944 ->IsNull()); | 945 ->IsNull()); |
945 } | 946 } |
946 | 947 |
947 } // namespace | 948 } // namespace |
948 } // namespace blink | 949 } // namespace blink |
OLD | NEW |