Title: [239211] trunk
Revision
239211
Author
[email protected]
Date
2018-12-14 09:44:47 -0800 (Fri, 14 Dec 2018)

Log Message

IDB should store RTCCertificate
https://bugs.webkit.org/show_bug.cgi?id=192599

Reviewed by Brady Eidson.

Source/WebCore:

In case there is no script execution context, do not create a JS DOM wrapper for RTCCertificate.
Instead, create an empty object so that the deserialization can still succeed.
This should only impact IDB deserialization in the Network Process which does not need the actual JS DOM wrapper.

Test: webrtc/certificates-indexeddb.html

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readTerminal):

LayoutTests:

* webrtc/certificates-indexeddb-expected.txt: Added.
* webrtc/certificates-indexeddb.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239210 => 239211)


--- trunk/LayoutTests/ChangeLog	2018-12-14 17:40:53 UTC (rev 239210)
+++ trunk/LayoutTests/ChangeLog	2018-12-14 17:44:47 UTC (rev 239211)
@@ -1,3 +1,13 @@
+2018-12-14  Youenn Fablet  <[email protected]>
+
+        IDB should store RTCCertificate
+        https://bugs.webkit.org/show_bug.cgi?id=192599
+
+        Reviewed by Brady Eidson.
+
+        * webrtc/certificates-indexeddb-expected.txt: Added.
+        * webrtc/certificates-indexeddb.html: Added.
+
 2018-12-13  Ryosuke Niwa  <[email protected]>
 
         Make HTMLConverter work across shadow boundaries

Added: trunk/LayoutTests/webrtc/certificates-indexeddb-expected.txt (0 => 239211)


--- trunk/LayoutTests/webrtc/certificates-indexeddb-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/certificates-indexeddb-expected.txt	2018-12-14 17:44:47 UTC (rev 239211)
@@ -0,0 +1,3 @@
+
+PASS Testing certificates IndexedDB storage 
+

Added: trunk/LayoutTests/webrtc/certificates-indexeddb.html (0 => 239211)


--- trunk/LayoutTests/webrtc/certificates-indexeddb.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/certificates-indexeddb.html	2018-12-14 17:44:47 UTC (rev 239211)
@@ -0,0 +1,54 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing certificates IndexedDB storage</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script>
+let certificate;
+
+function storeKey() {
+    var objectStore = db.transaction("certificate", "readwrite").objectStore("certificate");
+    var req = objectStore.put(certificate, "mycertificate");
+    req._onerror_ = function(event) {
+        assert_unreached("Could not put a key into database: " + event.target.error.name);
+    }
+    req._onsuccess_ = function(event) { readKey(); }
+}
+
+function readKey() {
+    var objectStore = db.transaction("certificate").objectStore("certificate");
+    var req = objectStore.get("mycertificate");
+    req._onerror_ = function(event) {
+        assert_not_reached("Could not get a key from database: " + event.target.error.name);
+    }
+    req._onsuccess_ = function(event) {
+        assert_not_equals(event.target.result, undefined);
+        assert_equals(event.target.result.expires, certificate.expires);
+        done();
+    }
+}
+
+async function doTest() {
+    certificate = await  RTCPeerConnection.generateCertificate({ name: 'ECDSA', namedCurve: 'P-256' });
+
+    var openRequest = indexedDB.open("rtc");
+    openRequest._onupgradeneeded_ = function(event) {
+        var objectStore = event.target.result.createObjectStore("certificate");
+    }
+    openRequest._onerror_ = function(event) {
+        assert_not_reached("Could not open database: " + event.target.error.name);
+    }
+    openRequest._onsuccess_ = function(event) {
+        db = event.target.result;
+        storeKey();
+    }
+}
+doTest();
+
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (239210 => 239211)


--- trunk/Source/WebCore/ChangeLog	2018-12-14 17:40:53 UTC (rev 239210)
+++ trunk/Source/WebCore/ChangeLog	2018-12-14 17:44:47 UTC (rev 239211)
@@ -1,3 +1,19 @@
+2018-12-14  Youenn Fablet  <[email protected]>
+
+        IDB should store RTCCertificate
+        https://bugs.webkit.org/show_bug.cgi?id=192599
+
+        Reviewed by Brady Eidson.
+
+        In case there is no script execution context, do not create a JS DOM wrapper for RTCCertificate.
+        Instead, create an empty object so that the deserialization can still succeed.
+        This should only impact IDB deserialization in the Network Process which does not need the actual JS DOM wrapper.
+
+        Test: webrtc/certificates-indexeddb.html
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneDeserializer::readTerminal):
+
 2018-12-14  Zalan Bujtas  <[email protected]>
 
         [LFC][BFC] Transition to logical margin types.

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (239210 => 239211)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2018-12-14 17:40:53 UTC (rev 239210)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2018-12-14 17:44:47 UTC (rev 239211)
@@ -2717,6 +2717,9 @@
             fingerprints.uncheckedAppend(RTCCertificate::DtlsFingerprint { algorithm->string(), value->string() });
         }
 
+        if (!m_isDOMGlobalObject)
+            return constructEmptyObject(m_exec, m_globalObject->objectPrototype());
+
         auto rtcCertificate = RTCCertificate::create(SecurityOrigin::createFromString(origin->string()), expires, WTFMove(fingerprints), certificate->takeString(), keyedMaterial->takeString());
         return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), WTFMove(rtcCertificate));
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to