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

Unified Diff: third_party/WebKit/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp

Issue 2432493002: Handle RTCCertificate::fromPEM returning nullptr, with a unit test. (Closed)
Patch Set: Created 4 years, 2 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/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp
diff --git a/third_party/WebKit/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp b/third_party/WebKit/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp
index 366d6984052d4d4fe11a4d02f1fcfe4495192b00..c61fc75e9fb7cbed497ce85782a42d1bb5b1bd45 100644
--- a/third_party/WebKit/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp
+++ b/third_party/WebKit/Source/bindings/modules/v8/serialization/V8ScriptValueSerializerForModulesTest.cpp
@@ -155,6 +155,7 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripRTCCertificate) {
certificateGenerator->fromPEM(
WebString::fromUTF8(kEcdsaPrivateKey, sizeof(kEcdsaPrivateKey)),
WebString::fromUTF8(kEcdsaCertificate, sizeof(kEcdsaCertificate)));
+ ASSERT_TRUE(webCertificate);
RTCCertificate* certificate = new RTCCertificate(std::move(webCertificate));
// Round trip test.
@@ -191,6 +192,24 @@ TEST(V8ScriptValueSerializerForModulesTest, DecodeRTCCertificate) {
EXPECT_EQ(kEcdsaCertificate, pem.certificate());
}
+TEST(V8ScriptValueSerializerForModulesTest, DecodeInvalidRTCCertificate) {
+ ScopedEnableV8BasedStructuredClone enable;
+ V8TestingScope scope;
+
+ // This is valid, except that "private" is not a valid private key PEM and
+ // "certificate" is not a valid certificate PEM. This checks what happens if
+ // these fail validation inside WebRTC.
+ ScriptState* scriptState = scope.getScriptState();
+ RefPtr<SerializedScriptValue> input = serializedValue(
+ {0xff, 0x09, 0x3f, 0x00, 0x6b, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e',
+ 0x0b, 'c', 'e', 'r', 't', 'i', 'f', 'i', 'c', 'a', 't', 'e', 0x00});
+
+ // Decode test.
+ v8::Local<v8::Value> result =
+ V8ScriptValueDeserializerForModules(scriptState, input).deserialize();
+ EXPECT_TRUE(result->IsNull());
+}
+
// A bunch of voodoo which allows the asynchronous WebCrypto operations to be
// called synchronously, with the resulting JavaScript values extracted.

Powered by Google App Engine
This is Rietveld 408576698