<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194908] branches/safari-601.1.46-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194908">194908</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2016-01-12 11:31:20 -0800 (Tue, 12 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/192186">r192186</a>. rdar://problem/24101174</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestsChangeLog">branches/safari-601.1.46-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreCMakeListstxt">branches/safari-601.1.46-branch/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreChangeLog">branches/safari-601.1.46-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters">branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptHostcpp">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptHosth">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.h</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptManagercpp">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptManagerh">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.h</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorJSInjectedScriptHosth">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreChangeLog">branches/safari-601.1.46-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreWebCorevcxprojWebCorevcxproj">branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreinspectorCommandLineAPIHostcpp">branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreinspectorCommandLineAPIHosth">branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreinspectorCommandLineAPIModulecpp">branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIModule.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreinspectorWebInjectedScriptManagercpp">branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreinspectorWebInjectedScriptManagerh">branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/</li>
<li><a href="#branchessafari601146branchLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccessexpectedtxt">branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt</a></li>
<li><a href="#branchessafari601146branchLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccesshtml">branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorPerGlobalObjectWrapperWorldcpp">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp</a></li>
<li><a href="#branchessafari601146branchSourceJavaScriptCoreinspectorPerGlobalObjectWrapperWorldh">branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreForwardingHeadersinspectorPerGlobalObjectWrapperWorldh">branches/safari-601.1.46-branch/Source/WebCore/ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestshttptestsinspectorprotocolaccessinspectedobjectexpectedtxt">branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object-expected.txt</a></li>
<li><a href="#branchessafari601146branchLayoutTestshttptestsinspectorprotocolaccessinspectedobjecthtml">branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601146branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-01-11  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r192186. rdar://problem/24101174
+
+    2015-11-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: $0 stops working after navigating to a different domain
+            https://bugs.webkit.org/show_bug.cgi?id=147962
+
+            Reviewed by Brian Burg.
+
+            * TestExpectations:
+            * http/tests/inspector/console/access-inspected-object-expected.txt: Removed.
+            * http/tests/inspector/console/access-inspected-object.html: Removed.
+            * http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt: Added.
+            * http/tests/inspector/console/cross-domain-inspected-node-access.html: Added.
+            Rewrite the old test with the new testing infrastructure.
+            Test this particular case of cross origin CommandLineAPI usage ($0).
+
</ins><span class="cx"> 2015-12-21  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r194114.
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccessexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt (0 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt                                (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+CONSOLE MESSAGE: line 52: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
+CONSOLE MESSAGE: line 52: Blocked a frame with origin &quot;http://localhost:8000&quot; from accessing a frame with origin &quot;http://127.0.0.1:8000&quot;. Protocols, domains, and ports must match.
+Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. Bug 105423.
+
+
+
+== Running test suite: CommandLineAPI.$0.cross-frame
+-- Running test case: AttemptCrossFrame$0AccessFromMainFrame
+Setting $0 to node within subframe.
+PASS: MainFrame access to $0 node in subframe should be null.
+
+-- Running test case: AttemptSameFrame$0AccessFromMainFrame
+Setting $0 to node within the main frame.
+PASS: MainFrame access to $0 node in main frame should be a node.
+
+-- Running test case: AttemptCrossFrame$0AccessFromSubFrame
+Setting $0 to node within the main frame.
+PASS: SubFrame access to $0 node in main frame should be null.
+
+-- Running test case: AttemptSameFrame$0AccessFromSubFrame
+Setting $0 to node within the subframe.
+PASS: SubFrame access to $0 node in sub frame should be a node.
+
</ins></span></pre></div>
<a id="branchessafari601146branchLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccesshtml"></a>
<div class="addfile"><h4>Added: branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html (0 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html                                (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;../resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite(&quot;CommandLineAPI.$0.cross-frame&quot;);
+
+    let nodeInMainFrameId;
+    let nodeInSubFrameId;
+
+    suite.addTestCase({
+        name: &quot;AttemptCrossFrame$0AccessFromMainFrame&quot;,
+        description: &quot;Should not be able to access $0 node in different domain subframe from the main frame.&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorTest.log(&quot;Setting $0 to node within subframe.&quot;);
+            ConsoleAgent.addInspectedNode(nodeInSubFrameId);
+            RuntimeAgent.evaluate.invoke({expression: &quot;$0&quot;, includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) =&gt; {    
+                InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+                InspectorTest.assert(!wasThrown, &quot;Should not be an exception.&quot;);
+                let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+                InspectorTest.expectThat(remoteObject.value === null, &quot;MainFrame access to $0 node in subframe should be null.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;AttemptSameFrame$0AccessFromMainFrame&quot;,
+        description: &quot;Should be able to access $0 node in the same frame.&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorTest.log(&quot;Setting $0 to node within the main frame.&quot;);
+            ConsoleAgent.addInspectedNode(nodeInMainFrameId);
+            RuntimeAgent.evaluate.invoke({expression: &quot;$0&quot;, includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) =&gt; {
+                InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+                InspectorTest.assert(!wasThrown, &quot;Should not be an exception.&quot;);
+                let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+                InspectorTest.expectThat(remoteObject.isNode(), &quot;MainFrame access to $0 node in main frame should be a node.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;AttemptCrossFrame$0AccessFromSubFrame&quot;,
+        description: &quot;Should not be able to access $0 node in different domain main frame from the subframe.&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorTest.log(&quot;Setting $0 to node within the main frame.&quot;);
+            ConsoleAgent.addInspectedNode(nodeInMainFrameId);
+            const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
+            RuntimeAgent.evaluate.invoke({expression: &quot;$0&quot;, includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) =&gt; {    
+                InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+                InspectorTest.assert(!wasThrown, &quot;Should not be an exception.&quot;);
+                let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+                InspectorTest.expectThat(remoteObject.value === null, &quot;SubFrame access to $0 node in main frame should be null.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;AttemptSameFrame$0AccessFromSubFrame&quot;,
+        description: &quot;Should be able to access $0 node in the same frame.&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorTest.log(&quot;Setting $0 to node within the subframe.&quot;);
+            ConsoleAgent.addInspectedNode(nodeInSubFrameId);
+            const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
+            RuntimeAgent.evaluate.invoke({expression: &quot;$0&quot;, includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) =&gt; {
+                InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+                InspectorTest.assert(!wasThrown, &quot;Should not be an exception.&quot;);
+                let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+                InspectorTest.expectThat(remoteObject.isNode(), &quot;SubFrame access to $0 node in sub frame should be a node.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    WebInspector.domTreeManager.requestDocument((documentNode) =&gt; {
+        WebInspector.domTreeManager.querySelector(documentNode.id, &quot;iframe#myframe&quot;, (nodeId) =&gt; {
+            let iframeNode = WebInspector.domTreeManager.nodeForId(nodeId);
+            let iframeDocumentNodeId = iframeNode.children[0].id;
+            WebInspector.domTreeManager.querySelector(iframeDocumentNodeId, &quot;div#rootDiv&quot;, (nodeId) =&gt; {
+                nodeInMainFrameId = iframeNode.id;
+                nodeInSubFrameId = nodeId;
+                suite.runTestCasesAndFinish();
+            });
+        });
+    });
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=105423&quot;&gt;Bug 105423.&lt;/a&gt;&lt;/p&gt;
+&lt;iframe id=&quot;myframe&quot; src=&quot;http://localhost:8000/inspector/page/resources/test-page.html&quot; onload=&quot;runTest()&quot;&gt;&lt;/iframe&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari601146branchLayoutTestshttptestsinspectorprotocolaccessinspectedobjectexpectedtxt"></a>
<div class="delfile"><h4>Deleted: branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object-expected.txt (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object-expected.txt        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object-expected.txt        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1,4 +0,0 @@
</span><del>-CONSOLE MESSAGE: line 52: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
-Test that code evaluated in the main frame cannot access $0 that resolves into a node in a frame from a different domain. Bug 105423.
-

</del></span></pre></div>
<a id="branchessafari601146branchLayoutTestshttptestsinspectorprotocolaccessinspectedobjecthtml"></a>
<div class="delfile"><h4>Deleted: branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object.html (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object.html        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/inspector-protocol/access-inspected-object.html        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1,75 +0,0 @@
</span><del>-&lt;html&gt;
-&lt;head&gt;
-&lt;script type=&quot;text/javascript&quot; src=&quot;resources/protocol-test.js&quot;&gt;&lt;/script&gt;
-&lt;script&gt;
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
-
-function test()
-{
-    InspectorTest.sendCommand(&quot;DOM.getDocument&quot;, {}, didGetDocument);
-
-    function didGetDocument(messageObject)
-    {
-        InspectorTest.sendCommand(&quot;DOM.querySelector&quot;, {
-                &quot;nodeId&quot;: messageObject.result.root.nodeId,
-                &quot;selector&quot;: &quot;iframe#myframe&quot;
-            }, didFindIframe);
-        InspectorTest.eventHandler[&quot;DOM.setChildNodes&quot;] = iframeRequestHandler;
-    }
-
-    function didFindIframe(messageObject)
-    {
-        if (messageObject.error) {
-            InspectorTest.log(&quot;FAIL: &quot; + messageObject.error);
-            InspectorTest.completeTest();
-        }
-    }
-
-    function iframeRequestHandler(messageObject)
-    {
-        var node = messageObject.params.nodes[0];
-        if (!node || node.nodeName !== &quot;IFRAME&quot;)
-            return;
-        InspectorTest.eventHandler[&quot;DOM.setChildNodes&quot;] = null;
-        InspectorTest.sendCommand(&quot;DOM.querySelector&quot;, {
-                &quot;nodeId&quot;: node.contentDocument.nodeId,
-                &quot;selector&quot;: &quot;div#rootDiv&quot;
-            }, didFindDiv);
-    }
-
-    function didFindDiv(messageObject)
-    {
-        InspectorTest.sendCommand(&quot;Console.enable&quot;, {});
-        InspectorTest.sendCommand(&quot;Console.addInspectedNode&quot;, {
-                &quot;nodeId&quot;: messageObject.result.nodeId
-            }, didAddInspectedNode);
-    }
-
-    function didAddInspectedNode(messageObject)
-    {
-        InspectorTest.sendCommand(&quot;Runtime.evaluate&quot;, {
-                &quot;expression&quot;: &quot;$0&quot;,
-                &quot;includeCommandLineAPI&quot;: true
-            }, didEvaluate);
-    }
-
-    function didEvaluate(messageObject)
-    {
-        if (messageObject.result.wasThrown)
-            InspectorTest.log(&quot;FAIL: unexpected exception: &quot; + JSON.stringify(messageObject, null, 2));
-        if (messageObject.result.result.value !== null)
-            InspectorTest.log(&quot;FAIL: unexpected value: &quot; + JSON.stringify(messageObject, null, 2));
-        InspectorTest.completeTest();
-    }
-}
-
-&lt;/script&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;p&gt;Test that code evaluated in the main frame cannot access $0 that resolves into a node in a frame from a different domain. &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=105423&quot;&gt;Bug 105423.&lt;/p&gt;
-&lt;iframe id=&quot;myframe&quot; src=&quot;http://localhost:8000/inspector-protocol/resources/test-page.html&quot; onload=&quot;runTest()&quot;&gt;&lt;/iframe&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/CMakeLists.txt (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/CMakeLists.txt        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/CMakeLists.txt        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -320,6 +320,7 @@
</span><span class="cx">     inspector/JSJavaScriptCallFrame.cpp
</span><span class="cx">     inspector/JSJavaScriptCallFramePrototype.cpp
</span><span class="cx">     inspector/JavaScriptCallFrame.cpp
</span><ins>+    inspector/PerGlobalObjectWrapperWorld.cpp
</ins><span class="cx">     inspector/ScriptArguments.cpp
</span><span class="cx">     inspector/ScriptCallFrame.cpp
</span><span class="cx">     inspector/ScriptCallStack.cpp
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/ChangeLog (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/ChangeLog        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/ChangeLog        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1,3 +1,61 @@
</span><ins>+2016-01-11  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r192186. rdar://problem/24101174
+
+    2015-11-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: $0 stops working after navigating to a different domain
+            https://bugs.webkit.org/show_bug.cgi?id=147962
+
+            Reviewed by Brian Burg.
+
+            Extract the per-GlobalObject cache of JSValue wrappers for
+            InjectedScriptHost objects to be reused by WebCore for its
+            CommandLineAPIHost objects injected into multiple contexts.
+
+            * CMakeLists.txt:
+            * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+            * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+            * JavaScriptCore.xcodeproj/project.pbxproj:
+            Add new files.
+
+            * inspector/PerGlobalObjectWrapperWorld.h:
+            * inspector/PerGlobalObjectWrapperWorld.cpp:
+            (Inspector::PerGlobalObjectWrapperWorld::getWrapper):
+            (Inspector::PerGlobalObjectWrapperWorld::addWrapper):
+            (Inspector::PerGlobalObjectWrapperWorld::clearAllWrappers):
+            Hold a bunch of per-global-object wrappers for an object
+            that will outlive the global object. This inspector does this
+            for host objects that it exposes into scripts it injects into
+            each execution context created by the page.
+
+            * inspector/InjectedScriptHost.cpp:
+            (Inspector::InjectedScriptHost::wrapper):
+            (Inspector::InjectedScriptHost::clearAllWrappers):
+            (Inspector::InjectedScriptHost::jsWrapper): Deleted.
+            (Inspector::clearWrapperFromValue): Deleted.
+            (Inspector::InjectedScriptHost::clearWrapper): Deleted.
+            Extract and simplify the Per-GlobalObject wrapping into a class.
+            Simplify object construction as well.
+
+            * inspector/InjectedScriptHost.h:
+            * inspector/InjectedScriptManager.cpp:
+            (Inspector::InjectedScriptManager::createInjectedScript):
+            (Inspector::InjectedScriptManager::discardInjectedScripts):
+            Make discarding virtual so subclasses may also discard injected scripts.
+
+            * inspector/JSInjectedScriptHost.cpp:
+            (Inspector::JSInjectedScriptHost::JSInjectedScriptHost):
+            (Inspector::JSInjectedScriptHost::releaseImpl): Deleted.
+            (Inspector::JSInjectedScriptHost::~JSInjectedScriptHost): Deleted.
+            (Inspector::toJS): Deleted.
+            (Inspector::toJSInjectedScriptHost): Deleted.
+            * inspector/JSInjectedScriptHost.h:
+            (Inspector::JSInjectedScriptHost::create):
+            (Inspector::JSInjectedScriptHost::impl):
+            Update this code originally copied from older generated bindings to
+            be more like new generated bindings and remove some now unused code.
+
</ins><span class="cx"> 2015-12-04  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r192391. rdar://problem/23581597
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -590,6 +590,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\JSJavaScriptCallFrame.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\JSJavaScriptCallFramePrototype.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\JavaScriptCallFrame.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\inspector\PerGlobalObjectWrapperWorld.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\ScriptArguments.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\ScriptCallFrame.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\ScriptCallStack.cpp&quot; /&gt;
</span><span class="lines">@@ -1346,6 +1347,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\JSJavaScriptCallFrame.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\JSJavaScriptCallFramePrototype.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\JavaScriptCallFrame.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\inspector\PerGlobalObjectWrapperWorld.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ScriptArguments.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ScriptBreakpoint.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ScriptCallFrame.h&quot; /&gt;
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1622,6 +1622,8 @@
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bytecode\PolymorphicGetByIdList.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;bytecode&lt;/Filter&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\inspector\PerGlobalObjectWrapperWorld.cpp&quot;&gt;
+      &lt;Filter&gt;inspector&lt;/Filter&gt;
</ins><span class="cx">     &lt;/ClCompile&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\profiler\ProfilerJettisonReason.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;profiler&lt;/Filter&gt;
</span><span class="lines">@@ -4094,6 +4096,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\JSJavaScriptCallFrame.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\inspector\PerGlobalObjectWrapperWorld.h&quot;&gt;
+      &lt;Filter&gt;inspector&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\runtime\JSCInlines.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;runtime&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1263,6 +1263,8 @@
</span><span class="cx">                 A59455921824744700CC3843 /* JSGlobalObjectDebuggable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A59455901824744700CC3843 /* JSGlobalObjectDebuggable.cpp */; };
</span><span class="cx">                 A59455931824744700CC3843 /* JSGlobalObjectDebuggable.h in Headers */ = {isa = PBXBuildFile; fileRef = A59455911824744700CC3843 /* JSGlobalObjectDebuggable.h */; };
</span><span class="cx">                 A5945595182479EB00CC3843 /* InspectorFrontendChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = A5945594182479EB00CC3843 /* InspectorFrontendChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                A5AB49DC1BEC8082007020FB /* PerGlobalObjectWrapperWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AB49DA1BEC8079007020FB /* PerGlobalObjectWrapperWorld.cpp */; };
+                A5AB49DD1BEC8086007020FB /* PerGlobalObjectWrapperWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 A5B6A74D18C6DBA600F11E91 /* ConsoleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */; };
</span><span class="cx">                 A5BA15E8182340B300A82E69 /* RemoteInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E1182340B300A82E69 /* RemoteInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A5BA15E9182340B300A82E69 /* RemoteInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15E2182340B300A82E69 /* RemoteInspector.mm */; };
</span><span class="lines">@@ -1660,6 +1662,8 @@
</span><span class="cx">                 E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE0D4A061AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */; };
</span><span class="cx">                 FE0D4A091ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A071ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp */; };
</span><ins>+                FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */; };
+                FE1220281BE7F5910039E6F2 /* JITAddGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1220251BE7F5640039E6F2 /* JITAddGenerator.cpp */; };
</ins><span class="cx">                 FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE1C0FFF1B194FD100B53FCA /* Exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1C0FFE1B194FD100B53FCA /* Exception.cpp */; };
</span><span class="cx">                 FE20CE9D15F04A9500DF3430 /* LLIntCLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE20CE9B15F04A9500DF3430 /* LLIntCLoop.cpp */; };
</span><span class="lines">@@ -1668,6 +1672,7 @@
</span><span class="cx">                 FE384EE61ADDB7AD0055DE2C /* JSDollarVM.h in Headers */ = {isa = PBXBuildFile; fileRef = FE384EE21ADDB7AD0055DE2C /* JSDollarVM.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FE384EE71ADDB7AD0055DE2C /* JSDollarVMPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE384EE31ADDB7AD0055DE2C /* JSDollarVMPrototype.cpp */; };
</span><span class="cx">                 FE384EE81ADDB7AD0055DE2C /* JSDollarVMPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = FE384EE41ADDB7AD0055DE2C /* JSDollarVMPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                FE4238901BE18C3C00514737 /* JITSubGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE42388F1BE18C1200514737 /* JITSubGenerator.cpp */; };
</ins><span class="cx">                 FE4BFF2B1AD476E700088F87 /* FunctionOverrides.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */; };
</span><span class="cx">                 FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */; };
</span><span class="cx">                 FE4D55B81AE716CA0052E459 /* IterationStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4D55B71AE716CA0052E459 /* IterationStatus.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -3038,6 +3043,8 @@
</span><span class="cx">                 A59455901824744700CC3843 /* JSGlobalObjectDebuggable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObjectDebuggable.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A59455911824744700CC3843 /* JSGlobalObjectDebuggable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectDebuggable.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5945594182479EB00CC3843 /* InspectorFrontendChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendChannel.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A5AB49DA1BEC8079007020FB /* PerGlobalObjectWrapperWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerGlobalObjectWrapperWorld.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerGlobalObjectWrapperWorld.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5BA15E1182340B300A82E69 /* RemoteInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspector.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5BA15E2182340B300A82E69 /* RemoteInspector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspector.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5501,6 +5508,8 @@
</span><span class="cx">                                 A503FA16188E0FB000110F14 /* JSJavaScriptCallFrame.h */,
</span><span class="cx">                                 A503FA17188E0FB000110F14 /* JSJavaScriptCallFramePrototype.cpp */,
</span><span class="cx">                                 A503FA18188E0FB000110F14 /* JSJavaScriptCallFramePrototype.h */,
</span><ins>+                                A5AB49DA1BEC8079007020FB /* PerGlobalObjectWrapperWorld.cpp */,
+                                A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */,
</ins><span class="cx">                                 A5FD0065189AFE9C00633231 /* ScriptArguments.cpp */,
</span><span class="cx">                                 A5FD0066189AFE9C00633231 /* ScriptArguments.h */,
</span><span class="cx">                                 A503FA1F188EFF6800110F14 /* ScriptBreakpoint.h */,
</span><span class="lines">@@ -6161,6 +6170,7 @@
</span><span class="cx">                                 86E3C613167BABD7006D760A /* JSContext.h in Headers */,
</span><span class="cx">                                 86E3C617167BABEE006D760A /* JSContextInternal.h in Headers */,
</span><span class="cx">                                 BC18C41E0E16F5CD00B34460 /* JSContextRef.h in Headers */,
</span><ins>+                                A5AB49DD1BEC8086007020FB /* PerGlobalObjectWrapperWorld.h in Headers */,
</ins><span class="cx">                                 148CD1D8108CF902008163C6 /* JSContextRefPrivate.h in Headers */,
</span><span class="cx">                                 A72028B81797601E0098028C /* JSCTestRunnerUtils.h in Headers */,
</span><span class="cx">                                 0F7576D318E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h in Headers */,
</span><span class="lines">@@ -7488,6 +7498,7 @@
</span><span class="cx">                                 0F4CED5E18CEA7AB00802FE0 /* PolymorphicGetByIdList.cpp in Sources */,
</span><span class="cx">                                 14469DDE107EC7E700650446 /* Lookup.cpp in Sources */,
</span><span class="cx">                                 0F4680CC14BBB17A00BFE272 /* LowLevelInterpreter.cpp in Sources */,
</span><ins>+                                A5AB49DC1BEC8082007020FB /* PerGlobalObjectWrapperWorld.cpp in Sources */,
</ins><span class="cx">                                 14B723B212D7DA46003BD5ED /* MachineStackMarker.cpp in Sources */,
</span><span class="cx">                                 0FEB3ECF16237F6C00AB67AD /* MacroAssembler.cpp in Sources */,
</span><span class="cx">                                 86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptHostcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InjectedScriptHost.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;JSCInlines.h&quot;
</ins><span class="cx"> #include &quot;JSInjectedScriptHost.h&quot;
</span><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="lines">@@ -36,44 +37,23 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue InjectedScriptHost::jsWrapper(ExecState* exec, JSGlobalObject* globalObject)
</del><ins>+JSValue InjectedScriptHost::wrapper(ExecState* exec, JSGlobalObject* globalObject)
</ins><span class="cx"> {
</span><del>-    auto key = std::make_pair(exec, globalObject);
-    auto it = m_wrappers.find(key);
-    if (it != m_wrappers.end())
-        return it-&gt;value.get();
</del><ins>+    JSValue value = m_wrappers.getWrapper(globalObject);
+    if (value)
+        return value;
</ins><span class="cx"> 
</span><del>-    JSValue jsValue = toJS(exec, globalObject, this);
-    if (!jsValue.isObject())
-        return jsValue;
</del><ins>+    JSObject* prototype = JSInjectedScriptHost::createPrototype(exec-&gt;vm(), globalObject);
+    Structure* structure = JSInjectedScriptHost::createStructure(exec-&gt;vm(), globalObject, prototype);
+    JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec-&gt;vm(), structure, Ref&lt;InjectedScriptHost&gt;(*this));
+    m_wrappers.addWrapper(globalObject, injectedScriptHost);
</ins><span class="cx"> 
</span><del>-    JSObject* jsObject = jsValue.toObject(exec, globalObject);
-    Strong&lt;JSObject&gt; wrapper(exec-&gt;vm(), jsObject);
-    m_wrappers.add(key, wrapper);
-
-    return jsValue;
</del><ins>+    return injectedScriptHost;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void clearWrapperFromValue(JSValue value)
-{
-    JSInjectedScriptHost* jsInjectedScriptHost = toJSInjectedScriptHost(value);
-    ASSERT(jsInjectedScriptHost);
-    if (jsInjectedScriptHost)
-        jsInjectedScriptHost-&gt;releaseImpl();
-}
-
-void InjectedScriptHost::clearWrapper(ExecState* exec, JSGlobalObject* globalObject)
-{
-    auto key = std::make_pair(exec, globalObject);
-    clearWrapperFromValue(m_wrappers.take(key).get());
-}
-
</del><span class="cx"> void InjectedScriptHost::clearAllWrappers()
</span><span class="cx"> {
</span><del>-    for (auto&amp; wrapper : m_wrappers)
-        clearWrapperFromValue(wrapper.value.get());
-
-    m_wrappers.clear();
</del><ins>+    m_wrappers.clearAllWrappers();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptHosth"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.h (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.h        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -27,8 +27,7 @@
</span><span class="cx"> #define InjectedScriptHost_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;JSCJSValueInlines.h&quot;
</span><del>-#include &quot;Strong.h&quot;
-#include &quot;StrongInlines.h&quot;
</del><ins>+#include &quot;inspector/PerGlobalObjectWrapperWorld.h&quot;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -42,12 +41,11 @@
</span><span class="cx">     virtual JSC::JSValue subtype(JSC::ExecState*, JSC::JSValue) { return JSC::jsUndefined(); }
</span><span class="cx">     virtual bool isHTMLAllCollection(JSC::JSValue) { return false; }
</span><span class="cx"> 
</span><del>-    JSC::JSValue jsWrapper(JSC::ExecState*, JSC::JSGlobalObject*);
-    void clearWrapper(JSC::ExecState*, JSC::JSGlobalObject*);
</del><ins>+    JSC::JSValue wrapper(JSC::ExecState*, JSC::JSGlobalObject*);
</ins><span class="cx">     void clearAllWrappers();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    HashMap&lt;std::pair&lt;JSC::ExecState*, JSC::JSGlobalObject*&gt;, JSC::Strong&lt;JSC::JSObject&gt;&gt; m_wrappers;
</del><ins>+    PerGlobalObjectWrapperWorld m_wrappers;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -60,6 +60,13 @@
</span><span class="cx">     discardInjectedScripts();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InjectedScriptManager::discardInjectedScripts()
+{
+    m_injectedScriptHost-&gt;clearAllWrappers();
+    m_idToInjectedScript.clear();
+    m_scriptStateToId.clear();
+}
+
</ins><span class="cx"> InjectedScriptHost* InjectedScriptManager::injectedScriptHost()
</span><span class="cx"> {
</span><span class="cx">     return m_injectedScriptHost.get();
</span><span class="lines">@@ -107,13 +114,6 @@
</span><span class="cx">     return m_idToInjectedScript.get(injectedScriptId);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InjectedScriptManager::discardInjectedScripts()
-{
-    m_injectedScriptHost-&gt;clearAllWrappers();
-    m_idToInjectedScript.clear();
-    m_scriptStateToId.clear();
-}
-
</del><span class="cx"> void InjectedScriptManager::releaseObjectGroup(const String&amp; objectGroup)
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; injectedScript : m_idToInjectedScript.values())
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">         return Deprecated::ScriptObject();
</span><span class="cx"> 
</span><span class="cx">     MarkedArgumentBuffer args;
</span><del>-    args.append(m_injectedScriptHost-&gt;jsWrapper(scriptState, globalObject));
</del><ins>+    args.append(m_injectedScriptHost-&gt;wrapper(scriptState, globalObject));
</ins><span class="cx">     args.append(globalThisValue);
</span><span class="cx">     args.append(jsNumber(id));
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.h (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.h        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptManager.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">     virtual ~InjectedScriptManager();
</span><span class="cx"> 
</span><span class="cx">     virtual void disconnect();
</span><ins>+    virtual void discardInjectedScripts();
</ins><span class="cx"> 
</span><span class="cx">     InjectedScriptHost* injectedScriptHost();
</span><span class="cx">     InspectorEnvironment&amp; inspectorEnvironment() const { return m_environment; }
</span><span class="lines">@@ -62,7 +63,6 @@
</span><span class="cx">     InjectedScript injectedScriptForId(int);
</span><span class="cx">     int injectedScriptIdFor(JSC::ExecState*);
</span><span class="cx">     InjectedScript injectedScriptForObjectId(const String&amp; objectId);
</span><del>-    void discardInjectedScripts();
</del><span class="cx">     void releaseObjectGroup(const String&amp; objectGroup);
</span><span class="cx">     void clearExceptionValue();
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -62,9 +62,9 @@
</span><span class="cx"> 
</span><span class="cx"> const ClassInfo JSInjectedScriptHost::s_info = { &quot;InjectedScriptHost&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSInjectedScriptHost) };
</span><span class="cx"> 
</span><del>-JSInjectedScriptHost::JSInjectedScriptHost(VM&amp; vm, Structure* structure, PassRefPtr&lt;InjectedScriptHost&gt; impl)
</del><ins>+JSInjectedScriptHost::JSInjectedScriptHost(VM&amp; vm, Structure* structure, Ref&lt;InjectedScriptHost&gt;&amp;&amp; impl)
</ins><span class="cx">     : JSDestructibleObject(vm, structure)
</span><del>-    , m_impl(impl.leakRef())
</del><ins>+    , m_wrapped(WTF::move(impl))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -85,17 +85,6 @@
</span><span class="cx">     thisObject-&gt;JSInjectedScriptHost::~JSInjectedScriptHost();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSInjectedScriptHost::releaseImpl()
-{
-    if (auto impl = std::exchange(m_impl, nullptr))
-        impl-&gt;deref();
-}
-
-JSInjectedScriptHost::~JSInjectedScriptHost()
-{
-    releaseImpl();
-}
-
</del><span class="cx"> JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const
</span><span class="cx"> {
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;lexicalGlobalObject();
</span><span class="lines">@@ -478,21 +467,4 @@
</span><span class="cx">     return array;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue toJS(ExecState* exec, JSGlobalObject* globalObject, InjectedScriptHost* impl)
-{
-    if (!impl)
-        return jsNull();
-
-    JSObject* prototype = JSInjectedScriptHost::createPrototype(exec-&gt;vm(), globalObject);
-    Structure* structure = JSInjectedScriptHost::createStructure(exec-&gt;vm(), globalObject, prototype);
-    JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec-&gt;vm(), structure, impl);
-
-    return injectedScriptHost;
-}
-
-JSInjectedScriptHost* toJSInjectedScriptHost(JSValue value)
-{
-    return value.inherits(JSInjectedScriptHost::info()) ? jsCast&lt;JSInjectedScriptHost*&gt;(value) : nullptr;
-}
-
</del><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorJSInjectedScriptHosth"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -28,10 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;JSDestructibleObject.h&quot;
</span><span class="cx"> 
</span><del>-namespace JSC {
-class WeakMapData;
-}
-
</del><span class="cx"> namespace Inspector {
</span><span class="cx"> 
</span><span class="cx"> class InjectedScriptHost;
</span><span class="lines">@@ -48,9 +44,9 @@
</span><span class="cx">         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static JSInjectedScriptHost* create(JSC::VM&amp; vm, JSC::Structure* structure, PassRefPtr&lt;InjectedScriptHost&gt; impl)
</del><ins>+    static JSInjectedScriptHost* create(JSC::VM&amp; vm, JSC::Structure* structure, Ref&lt;InjectedScriptHost&gt;&amp;&amp; impl)
</ins><span class="cx">     {
</span><del>-        JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell&lt;JSInjectedScriptHost&gt;(vm.heap)) JSInjectedScriptHost(vm, structure, impl);
</del><ins>+        JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell&lt;JSInjectedScriptHost&gt;(vm.heap)) JSInjectedScriptHost(vm, structure, WTF::move(impl));
</ins><span class="cx">         instance-&gt;finishCreation(vm);
</span><span class="cx">         return instance;
</span><span class="cx">     }
</span><span class="lines">@@ -58,8 +54,7 @@
</span><span class="cx">     static JSC::JSObject* createPrototype(JSC::VM&amp;, JSC::JSGlobalObject*);
</span><span class="cx">     static void destroy(JSC::JSCell*);
</span><span class="cx"> 
</span><del>-    InjectedScriptHost&amp; impl() const { return *m_impl; }
-    void releaseImpl();
</del><ins>+    InjectedScriptHost&amp; impl() const { return const_cast&lt;InjectedScriptHost&amp;&gt;(m_wrapped.get()); }
</ins><span class="cx"> 
</span><span class="cx">     // Attributes.
</span><span class="cx">     JSC::JSValue evaluate(JSC::ExecState*) const;
</span><span class="lines">@@ -80,15 +75,11 @@
</span><span class="cx">     void finishCreation(JSC::VM&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    JSInjectedScriptHost(JSC::VM&amp;, JSC::Structure*, PassRefPtr&lt;InjectedScriptHost&gt;);
-    ~JSInjectedScriptHost();
</del><ins>+    JSInjectedScriptHost(JSC::VM&amp;, JSC::Structure*, Ref&lt;InjectedScriptHost&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><del>-    InjectedScriptHost* m_impl;
</del><ins>+    Ref&lt;InjectedScriptHost&gt; m_wrapped;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, InjectedScriptHost*);
-JSInjectedScriptHost* toJSInjectedScriptHost(JSC::JSValue);
-
</del><span class="cx"> } // namespace Inspector
</span><span class="cx"> 
</span><span class="cx"> #endif // !defined(JSInjectedScriptHost_h)
</span></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorPerGlobalObjectWrapperWorldcppfromrev194783branchessafari601146branchSourceWebCoreinspectorWebInjectedScriptManagerh"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp (from rev 194783, branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.h) (0 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;PerGlobalObjectWrapperWorld.h&quot;
+
+using namespace JSC;
+
+namespace Inspector {
+
+JSValue PerGlobalObjectWrapperWorld::getWrapper(JSGlobalObject* globalObject)
+{
+    auto it = m_wrappers.find(globalObject);
+    if (it != m_wrappers.end())
+        return it-&gt;value.get();
+    return JSValue();
+}
+
+void PerGlobalObjectWrapperWorld::addWrapper(JSGlobalObject* globalObject, JSObject* object)
+{
+    Strong&lt;JSObject&gt; wrapper(globalObject-&gt;vm(), object);
+    m_wrappers.add(globalObject, wrapper);
+}
+
+void PerGlobalObjectWrapperWorld::clearAllWrappers()
+{
+    m_wrappers.clear();
+}
+
+} // namespace Inspector
</ins></span></pre></div>
<a id="branchessafari601146branchSourceJavaScriptCoreinspectorPerGlobalObjectWrapperWorldhfromrev194783branchessafari601146branchSourceJavaScriptCoreinspectorInjectedScriptHosth"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h (from rev 194783, branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/InjectedScriptHost.h) (0 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/JavaScriptCore/inspector/PerGlobalObjectWrapperWorld.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PerGlobalObjectWrapperWorld_h
+#define PerGlobalObjectWrapperWorld_h
+
+#include &quot;JSCJSValueInlines.h&quot;
+#include &quot;Strong.h&quot;
+#include &quot;StrongInlines.h&quot;
+#include &lt;wtf/HashMap.h&gt;
+
+namespace Inspector {
+
+class JS_EXPORT_PRIVATE PerGlobalObjectWrapperWorld {
+public:
+    JSC::JSValue getWrapper(JSC::JSGlobalObject*);
+    void addWrapper(JSC::JSGlobalObject*, JSC::JSObject*);
+    void clearAllWrappers();
+
+private:
+    HashMap&lt;JSC::JSGlobalObject*, JSC::Strong&lt;JSC::JSObject&gt;&gt; m_wrappers;
+};
+
+} // namespace Inspector
+
+#endif // !defined(PerGlobalObjectWrapperWorld_h)
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2016-01-11  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r192186. rdar://problem/24101174
+
+    2015-11-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: $0 stops working after navigating to a different domain
+            https://bugs.webkit.org/show_bug.cgi?id=147962
+
+            Reviewed by Brian Burg.
+
+            Test: http/tests/inspector/console/cross-domain-inspected-node-access.html
+
+            The inspector backend injects the CommandLineAPI Source with a
+            corresponding CommandLineAPIHost into each execution context
+            created by the page (main frame, sub frames, etc).
+
+            When creating the JSValue wrapper for the CommandLineAPIHost using
+            the generated toJS(...) DOM bindings, we were using the cached
+            CommandLineAPIHost wrapper values in the single DOMWrapperWorld shared
+            across all frames. This meant that the first time the wrapper was
+            needed it was created in context A. But when needed for context B
+            it was using the wrapper created in context A. Using this wrapper
+            in context B was producing unexpected cross-origin warnings.
+
+            The solution taken here, is to create a new JSValue wrapper for
+            the CommandLineAPIHost per execution context. This way each time
+            the CommandLineAPIHost wrapper is used in a frame, it is using
+            the one created for that frame.
+
+            The C++ host object being wrapped has a lifetime equivalent to
+            the Page. It does not change in this patch. The wrapper values
+            are cleared on page navigation or when the page is closed, and
+            will be garbage collected.
+
+            * WebCore.vcxproj/WebCore.vcxproj:
+            * WebCore.vcxproj/WebCore.vcxproj.filters:
+            * ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h: Added.
+            New forwarding header.
+
+            * inspector/CommandLineAPIHost.h:
+            * inspector/CommandLineAPIHost.cpp:
+            (WebCore::CommandLineAPIHost::CommandLineAPIHost):
+            (WebCore::CommandLineAPIHost::wrapper):
+            Cached JSValue wrappers per GlobalObject.
+
+            (WebCore::CommandLineAPIHost::clearAllWrappers):
+            Clear any wrappers we have, including the $0 value itself
+            which we weren't explicitly clearing previously.
+
+            * inspector/CommandLineAPIModule.cpp:
+            (WebCore::CommandLineAPIModule::host):
+            Simplify creating the wrapper.
+
+            * inspector/WebInjectedScriptManager.h:
+            * inspector/WebInjectedScriptManager.cpp:
+            (WebCore::WebInjectedScriptManager::discardInjectedScripts):
+            When the main frame window object clears, also clear the
+            CommandLineAPI wrappers we may have created. Also take this
+            opportunity to clear any $0 value that may have pointed
+            to a value in the previous page.
+
</ins><span class="cx"> 2016-01-08  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;rdar://problem/24094651&gt; REGRESSION (193350): CrashTracer: [USER] com.apple.WebKit.WebContent at …: Inspector::CSSFrontendDispatcher::styleSheetRemoved + 768
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreForwardingHeadersinspectorPerGlobalObjectWrapperWorldh"></a>
<div class="addfile"><h4>Added: branches/safari-601.1.46-branch/Source/WebCore/ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h (0 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/WebCore/ForwardingHeaders/inspector/PerGlobalObjectWrapperWorld.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+#ifndef WebCore_FWD_PerGlobalObjectWrapperWorld_h
+#define WebCore_FWD_PerGlobalObjectWrapperWorld_h
+#include &lt;JavaScriptCore/PerGlobalObjectWrapperWorld.h&gt;
+#endif
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -19539,6 +19539,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\InspectorProtocolObjects.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\InspectorProtocolTypes.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\InspectorValues.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\PerGlobalObjectWrapperWorld.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\ScriptArguments.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\ScriptBreakpoint.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\ScriptCallFrame.h&quot; /&gt;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -11771,6 +11771,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\InspectorValues.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;ForwardingHeaders\inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\PerGlobalObjectWrapperWorld.h&quot;&gt;
+      &lt;Filter&gt;ForwardingHeaders\inspector&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\ForwardingHeaders\inspector\ScriptArguments.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;ForwardingHeaders\inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreinspectorCommandLineAPIHostcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -32,25 +32,23 @@
</span><span class="cx"> #include &quot;CommandLineAPIHost.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Database.h&quot;
</span><del>-#include &quot;Element.h&quot;
-#include &quot;Frame.h&quot;
-#include &quot;FrameLoader.h&quot;
-#include &quot;HTMLFrameOwnerElement.h&quot;
</del><span class="cx"> #include &quot;InspectorClient.h&quot;
</span><span class="cx"> #include &quot;InspectorDOMAgent.h&quot;
</span><span class="cx"> #include &quot;InspectorDOMStorageAgent.h&quot;
</span><span class="cx"> #include &quot;InspectorDatabaseAgent.h&quot;
</span><del>-#include &lt;inspector/InspectorFrontendDispatchers.h&gt;
</del><ins>+#include &quot;JSCommandLineAPIHost.h&quot;
+#include &quot;JSDOMGlobalObject.h&quot;
</ins><span class="cx"> #include &quot;Pasteboard.h&quot;
</span><span class="cx"> #include &quot;Storage.h&quot;
</span><del>-#include &quot;markup.h&quot;
</del><span class="cx"> #include &lt;bindings/ScriptValue.h&gt;
</span><span class="cx"> #include &lt;inspector/InspectorValues.h&gt;
</span><span class="cx"> #include &lt;inspector/agents/InspectorAgent.h&gt;
</span><span class="cx"> #include &lt;inspector/agents/InspectorConsoleAgent.h&gt;
</span><ins>+#include &lt;runtime/JSCInlines.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> 
</span><ins>+using namespace JSC;
</ins><span class="cx"> using namespace Inspector;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -61,13 +59,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CommandLineAPIHost::CommandLineAPIHost()
</span><del>-    : m_inspectorAgent(nullptr)
-    , m_consoleAgent(nullptr)
-    , m_domAgent(nullptr)
-    , m_domStorageAgent(nullptr)
-    , m_databaseAgent(nullptr)
</del><ins>+    : m_inspectedObject(std::make_unique&lt;InspectableObject&gt;())
</ins><span class="cx"> {
</span><del>-    m_inspectedObject = std::make_unique&lt;InspectableObject&gt;();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CommandLineAPIHost::~CommandLineAPIHost()
</span><span class="lines">@@ -144,4 +137,24 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue CommandLineAPIHost::wrapper(ExecState* exec, JSDOMGlobalObject* globalObject)
+{
+    JSValue value = m_wrappers.getWrapper(globalObject);
+    if (value)
+        return value;
+
+    JSObject* prototype = JSCommandLineAPIHost::createPrototype(exec-&gt;vm(), globalObject);
+    Structure* structure = JSCommandLineAPIHost::createStructure(exec-&gt;vm(), globalObject, prototype);
+    JSCommandLineAPIHost* commandLineAPIHost = JSCommandLineAPIHost::create(structure, globalObject, Ref&lt;CommandLineAPIHost&gt;(*this));
+    m_wrappers.addWrapper(globalObject, commandLineAPIHost);
+
+    return commandLineAPIHost;
+}
+
+void CommandLineAPIHost::clearAllWrappers()
+{
+    m_wrappers.clearAllWrappers();
+    m_inspectedObject = std::make_unique&lt;InspectableObject&gt;();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreinspectorCommandLineAPIHosth"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.h (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.h        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIHost.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> #define CommandLineAPIHost_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ScriptState.h&quot;
</span><del>-#include &lt;runtime/ConsoleTypes.h&gt;
</del><ins>+#include &lt;inspector/PerGlobalObjectWrapperWorld.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -40,6 +40,10 @@
</span><span class="cx"> class ScriptValue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace JSC {
+class JSValue;
+}
+
</ins><span class="cx"> namespace Inspector {
</span><span class="cx"> class InspectorAgent;
</span><span class="cx"> class InspectorConsoleAgent;
</span><span class="lines">@@ -53,6 +57,7 @@
</span><span class="cx"> class InspectorDOMAgent;
</span><span class="cx"> class InspectorDOMStorageAgent;
</span><span class="cx"> class InspectorDatabaseAgent;
</span><ins>+class JSDOMGlobalObject;
</ins><span class="cx"> class Node;
</span><span class="cx"> class Storage;
</span><span class="cx"> 
</span><span class="lines">@@ -97,16 +102,20 @@
</span><span class="cx">     String databaseIdImpl(Database*);
</span><span class="cx">     String storageIdImpl(Storage*);
</span><span class="cx"> 
</span><ins>+    JSC::JSValue wrapper(JSC::ExecState*, JSDOMGlobalObject*);
+    void clearAllWrappers();
+
</ins><span class="cx"> private:
</span><span class="cx">     CommandLineAPIHost();
</span><span class="cx"> 
</span><del>-    Inspector::InspectorAgent* m_inspectorAgent;
-    Inspector::InspectorConsoleAgent* m_consoleAgent;
-    InspectorDOMAgent* m_domAgent;
-    InspectorDOMStorageAgent* m_domStorageAgent;
-    InspectorDatabaseAgent* m_databaseAgent;
</del><ins>+    Inspector::InspectorAgent* m_inspectorAgent {nullptr};
+    Inspector::InspectorConsoleAgent* m_consoleAgent {nullptr};
+    InspectorDOMAgent* m_domAgent {nullptr};
+    InspectorDOMStorageAgent* m_domStorageAgent {nullptr};
+    InspectorDatabaseAgent* m_databaseAgent {nullptr};
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;InspectableObject&gt; m_inspectedObject; // $0
</span><ins>+    Inspector::PerGlobalObjectWrapperWorld m_wrappers;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreinspectorCommandLineAPIModulecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIModule.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIModule.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/CommandLineAPIModule.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -27,8 +27,7 @@
</span><span class="cx"> #include &quot;CommandLineAPIModule.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CommandLineAPIModuleSource.h&quot;
</span><del>-#include &quot;DOMWrapperWorld.h&quot;
-#include &quot;JSCommandLineAPIHost.h&quot;
</del><ins>+#include &quot;JSDOMGlobalObject.h&quot;
</ins><span class="cx"> #include &quot;WebInjectedScriptManager.h&quot;
</span><span class="cx"> #include &lt;inspector/InjectedScript.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -53,13 +52,14 @@
</span><span class="cx">     return StringImpl::createWithoutCopying(CommandLineAPIModuleSource_js, sizeof(CommandLineAPIModuleSource_js));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSC::JSValue CommandLineAPIModule::host(InjectedScriptManager* injectedScriptManager, JSC::ExecState* exec) const
</del><ins>+JSValue CommandLineAPIModule::host(InjectedScriptManager* injectedScriptManager, ExecState* exec) const
</ins><span class="cx"> {
</span><span class="cx">     // CommandLineAPIModule should only ever be used by a WebInjectedScriptManager.
</span><span class="cx">     WebInjectedScriptManager* pageInjectedScriptManager = static_cast&lt;WebInjectedScriptManager*&gt;(injectedScriptManager);
</span><span class="cx">     ASSERT(pageInjectedScriptManager-&gt;commandLineAPIHost());
</span><ins>+
</ins><span class="cx">     JSDOMGlobalObject* globalObject = jsCast&lt;JSDOMGlobalObject*&gt;(exec-&gt;lexicalGlobalObject());
</span><del>-    return toJS(exec, globalObject, pageInjectedScriptManager-&gt;commandLineAPIHost());
</del><ins>+    return pageInjectedScriptManager-&gt;commandLineAPIHost()-&gt;wrapper(exec, globalObject);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreinspectorWebInjectedScriptManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.cpp (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.cpp        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.cpp        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -47,6 +47,13 @@
</span><span class="cx">     m_commandLineAPIHost = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebInjectedScriptManager::discardInjectedScripts()
+{
+    InjectedScriptManager::discardInjectedScripts();
+
+    m_commandLineAPIHost-&gt;clearAllWrappers();
+}
+
</ins><span class="cx"> void WebInjectedScriptManager::didCreateInjectedScript(InjectedScript injectedScript)
</span><span class="cx"> {
</span><span class="cx">     CommandLineAPIModule::injectIfNeeded(this, injectedScript);
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreinspectorWebInjectedScriptManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.h (194907 => 194908)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.h        2016-01-12 19:27:18 UTC (rev 194907)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/WebInjectedScriptManager.h        2016-01-12 19:31:20 UTC (rev 194908)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx">     CommandLineAPIHost* commandLineAPIHost() const { return m_commandLineAPIHost.get(); }
</span><span class="cx"> 
</span><span class="cx">     virtual void disconnect() override;
</span><ins>+    virtual void discardInjectedScripts() override;
</ins><span class="cx"> 
</span><span class="cx">     void discardInjectedScriptsFor(DOMWindow*);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>