<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Setting navigationDelegate breaks WebCrypto API"
   href="https://bugs.webkit.org/show_bug.cgi?id=156553">156553</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Setting navigationDelegate  breaks WebCrypto API
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Safari 9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>iOS
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>iOS 9.3
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>trygve.hardersen&#64;gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm encountering strange behaviour in the WebCrypto API when setting the navigationDelegate of a WKWebView on iOS. After setting the delegate I can no longer store asymmetric keys from JavaScript as I'm getting a DataCloneError (25).

After looking through the source code I believe this is caused by this code in NavigationState.mm

m_navigationDelegateMethods.webCryptoMasterKeyForWebView = [delegate respondsToSelector:&#64;selector(_webCryptoMasterKeyForWebView:)];

I can work around the issue by implementing this method in by navigationDelegate class:

- (NSData *)_webCryptoMasterKeyForWebView:(WKWebView *)sender {
    return [NSData dataWithBytes:&quot;\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f&quot; length:16];
}

I've provided a sample key above. Obviously I would not like to rely on this private API.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>