<!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 <matthew_hanson@apple.com>
+
+ Merge r192186. rdar://problem/24101174
+
+ 2015-11-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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 <bshafiei@apple.com>
</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 "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
+CONSOLE MESSAGE: line 52: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". 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>+<!doctype html>
+<html>
+<head>
+<script type="text/javascript" src="../resources/inspector-test.js"></script>
+<script>
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("CommandLineAPI.$0.cross-frame");
+
+ let nodeInMainFrameId;
+ let nodeInSubFrameId;
+
+ suite.addTestCase({
+ name: "AttemptCrossFrame$0AccessFromMainFrame",
+ description: "Should not be able to access $0 node in different domain subframe from the main frame.",
+ test: (resolve, reject) => {
+ InspectorTest.log("Setting $0 to node within subframe.");
+ ConsoleAgent.addInspectedNode(nodeInSubFrameId);
+ RuntimeAgent.evaluate.invoke({expression: "$0", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.assert(!wasThrown, "Should not be an exception.");
+ let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+ InspectorTest.expectThat(remoteObject.value === null, "MainFrame access to $0 node in subframe should be null.");
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "AttemptSameFrame$0AccessFromMainFrame",
+ description: "Should be able to access $0 node in the same frame.",
+ test: (resolve, reject) => {
+ InspectorTest.log("Setting $0 to node within the main frame.");
+ ConsoleAgent.addInspectedNode(nodeInMainFrameId);
+ RuntimeAgent.evaluate.invoke({expression: "$0", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.assert(!wasThrown, "Should not be an exception.");
+ let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+ InspectorTest.expectThat(remoteObject.isNode(), "MainFrame access to $0 node in main frame should be a node.");
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "AttemptCrossFrame$0AccessFromSubFrame",
+ description: "Should not be able to access $0 node in different domain main frame from the subframe.",
+ test: (resolve, reject) => {
+ InspectorTest.log("Setting $0 to node within the main frame.");
+ ConsoleAgent.addInspectedNode(nodeInMainFrameId);
+ const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
+ RuntimeAgent.evaluate.invoke({expression: "$0", includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.assert(!wasThrown, "Should not be an exception.");
+ let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+ InspectorTest.expectThat(remoteObject.value === null, "SubFrame access to $0 node in main frame should be null.");
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "AttemptSameFrame$0AccessFromSubFrame",
+ description: "Should be able to access $0 node in the same frame.",
+ test: (resolve, reject) => {
+ InspectorTest.log("Setting $0 to node within the subframe.");
+ ConsoleAgent.addInspectedNode(nodeInSubFrameId);
+ const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
+ RuntimeAgent.evaluate.invoke({expression: "$0", includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.assert(!wasThrown, "Should not be an exception.");
+ let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+ InspectorTest.expectThat(remoteObject.isNode(), "SubFrame access to $0 node in sub frame should be a node.");
+ resolve();
+ });
+ }
+ });
+
+ WebInspector.domTreeManager.requestDocument((documentNode) => {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "iframe#myframe", (nodeId) => {
+ let iframeNode = WebInspector.domTreeManager.nodeForId(nodeId);
+ let iframeDocumentNodeId = iframeNode.children[0].id;
+ WebInspector.domTreeManager.querySelector(iframeDocumentNodeId, "div#rootDiv", (nodeId) => {
+ nodeInMainFrameId = iframeNode.id;
+ nodeInSubFrameId = nodeId;
+ suite.runTestCasesAndFinish();
+ });
+ });
+ });
+}
+</script>
+</head>
+<body>
+<p>Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. <a href="https://bugs.webkit.org/show_bug.cgi?id=105423">Bug 105423.</a></p>
+<iframe id="myframe" src="http://localhost:8000/inspector/page/resources/test-page.html" onload="runTest()"></iframe>
+</body>
+</html>
</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 "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". 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>-<html>
-<head>
-<script type="text/javascript" src="resources/protocol-test.js"></script>
-<script>
-if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
-}
-
-function test()
-{
- InspectorTest.sendCommand("DOM.getDocument", {}, didGetDocument);
-
- function didGetDocument(messageObject)
- {
- InspectorTest.sendCommand("DOM.querySelector", {
- "nodeId": messageObject.result.root.nodeId,
- "selector": "iframe#myframe"
- }, didFindIframe);
- InspectorTest.eventHandler["DOM.setChildNodes"] = iframeRequestHandler;
- }
-
- function didFindIframe(messageObject)
- {
- if (messageObject.error) {
- InspectorTest.log("FAIL: " + messageObject.error);
- InspectorTest.completeTest();
- }
- }
-
- function iframeRequestHandler(messageObject)
- {
- var node = messageObject.params.nodes[0];
- if (!node || node.nodeName !== "IFRAME")
- return;
- InspectorTest.eventHandler["DOM.setChildNodes"] = null;
- InspectorTest.sendCommand("DOM.querySelector", {
- "nodeId": node.contentDocument.nodeId,
- "selector": "div#rootDiv"
- }, didFindDiv);
- }
-
- function didFindDiv(messageObject)
- {
- InspectorTest.sendCommand("Console.enable", {});
- InspectorTest.sendCommand("Console.addInspectedNode", {
- "nodeId": messageObject.result.nodeId
- }, didAddInspectedNode);
- }
-
- function didAddInspectedNode(messageObject)
- {
- InspectorTest.sendCommand("Runtime.evaluate", {
- "expression": "$0",
- "includeCommandLineAPI": true
- }, didEvaluate);
- }
-
- function didEvaluate(messageObject)
- {
- if (messageObject.result.wasThrown)
- InspectorTest.log("FAIL: unexpected exception: " + JSON.stringify(messageObject, null, 2));
- if (messageObject.result.result.value !== null)
- InspectorTest.log("FAIL: unexpected value: " + JSON.stringify(messageObject, null, 2));
- InspectorTest.completeTest();
- }
-}
-
-</script>
-</head>
-<body>
-<p>Test that code evaluated in the main frame cannot access $0 that resolves into a node in a frame from a different domain. <a href="https://bugs.webkit.org/show_bug.cgi?id=105423">Bug 105423.</p>
-<iframe id="myframe" src="http://localhost:8000/inspector-protocol/resources/test-page.html" onload="runTest()"></iframe>
-</body>
-</html>
</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 <matthew_hanson@apple.com>
+
+ Merge r192186. rdar://problem/24101174
+
+ 2015-11-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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 <timothy@apple.com>
</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"> <ClCompile Include="..\inspector\JSJavaScriptCallFrame.cpp" />
</span><span class="cx"> <ClCompile Include="..\inspector\JSJavaScriptCallFramePrototype.cpp" />
</span><span class="cx"> <ClCompile Include="..\inspector\JavaScriptCallFrame.cpp" />
</span><ins>+ <ClCompile Include="..\inspector\PerGlobalObjectWrapperWorld.cpp" />
</ins><span class="cx"> <ClCompile Include="..\inspector\ScriptArguments.cpp" />
</span><span class="cx"> <ClCompile Include="..\inspector\ScriptCallFrame.cpp" />
</span><span class="cx"> <ClCompile Include="..\inspector\ScriptCallStack.cpp" />
</span><span class="lines">@@ -1346,6 +1347,7 @@
</span><span class="cx"> <ClInclude Include="..\inspector\JSJavaScriptCallFrame.h" />
</span><span class="cx"> <ClInclude Include="..\inspector\JSJavaScriptCallFramePrototype.h" />
</span><span class="cx"> <ClInclude Include="..\inspector\JavaScriptCallFrame.h" />
</span><ins>+ <ClInclude Include="..\inspector\PerGlobalObjectWrapperWorld.h" />
</ins><span class="cx"> <ClInclude Include="..\inspector\ScriptArguments.h" />
</span><span class="cx"> <ClInclude Include="..\inspector\ScriptBreakpoint.h" />
</span><span class="cx"> <ClInclude Include="..\inspector\ScriptCallFrame.h" />
</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"> </ClCompile>
</span><span class="cx"> <ClCompile Include="..\bytecode\PolymorphicGetByIdList.cpp">
</span><span class="cx"> <Filter>bytecode</Filter>
</span><ins>+ <ClCompile Include="..\inspector\PerGlobalObjectWrapperWorld.cpp">
+ <Filter>inspector</Filter>
</ins><span class="cx"> </ClCompile>
</span><span class="cx"> <ClCompile Include="..\profiler\ProfilerJettisonReason.cpp">
</span><span class="cx"> <Filter>profiler</Filter>
</span><span class="lines">@@ -4094,6 +4096,9 @@
</span><span class="cx"> <ClInclude Include="..\inspector\JSJavaScriptCallFrame.h">
</span><span class="cx"> <Filter>inspector</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\inspector\PerGlobalObjectWrapperWorld.h">
+ <Filter>inspector</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\runtime\JSCInlines.h">
</span><span class="cx"> <Filter>runtime</Filter>
</span><span class="cx"> </ClInclude>
</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 = "<group>"; };
</span><span class="cx">                 A59455911824744700CC3843 /* JSGlobalObjectDebuggable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectDebuggable.h; sourceTree = "<group>"; };
</span><span class="cx">                 A5945594182479EB00CC3843 /* InspectorFrontendChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendChannel.h; sourceTree = "<group>"; };
</span><ins>+                A5AB49DA1BEC8079007020FB /* PerGlobalObjectWrapperWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerGlobalObjectWrapperWorld.cpp; sourceTree = "<group>"; };
+                A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerGlobalObjectWrapperWorld.h; sourceTree = "<group>"; };
</ins><span class="cx">                 A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleClient.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 A5BA15E1182340B300A82E69 /* RemoteInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspector.h; sourceTree = "<group>"; };
</span><span class="cx">                 A5BA15E2182340B300A82E69 /* RemoteInspector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspector.mm; sourceTree = "<group>"; };
</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 "config.h"
</span><span class="cx"> #include "InjectedScriptHost.h"
</span><span class="cx">
</span><ins>+#include "JSCInlines.h"
</ins><span class="cx"> #include "JSInjectedScriptHost.h"
</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->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->vm(), globalObject);
+ Structure* structure = JSInjectedScriptHost::createStructure(exec->vm(), globalObject, prototype);
+ JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, Ref<InjectedScriptHost>(*this));
+ m_wrappers.addWrapper(globalObject, injectedScriptHost);
</ins><span class="cx">
</span><del>- JSObject* jsObject = jsValue.toObject(exec, globalObject);
- Strong<JSObject> wrapper(exec->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->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& 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 "JSCJSValueInlines.h"
</span><del>-#include "Strong.h"
-#include "StrongInlines.h"
</del><ins>+#include "inspector/PerGlobalObjectWrapperWorld.h"
</ins><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</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<std::pair<JSC::ExecState*, JSC::JSGlobalObject*>, JSC::Strong<JSC::JSObject>> 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->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->clearAllWrappers();
- m_idToInjectedScript.clear();
- m_scriptStateToId.clear();
-}
-
</del><span class="cx"> void InjectedScriptManager::releaseObjectGroup(const String& objectGroup)
</span><span class="cx"> {
</span><span class="cx"> for (auto& 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->jsWrapper(scriptState, globalObject));
</del><ins>+ args.append(m_injectedScriptHost->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& 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& objectId);
</span><del>- void discardInjectedScripts();
</del><span class="cx"> void releaseObjectGroup(const String& 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 = { "InjectedScriptHost", &Base::s_info, 0, CREATE_METHOD_TABLE(JSInjectedScriptHost) };
</span><span class="cx">
</span><del>-JSInjectedScriptHost::JSInjectedScriptHost(VM& vm, Structure* structure, PassRefPtr<InjectedScriptHost> impl)
</del><ins>+JSInjectedScriptHost::JSInjectedScriptHost(VM& vm, Structure* structure, Ref<InjectedScriptHost>&& 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->JSInjectedScriptHost::~JSInjectedScriptHost();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void JSInjectedScriptHost::releaseImpl()
-{
- if (auto impl = std::exchange(m_impl, nullptr))
- impl->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->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->vm(), globalObject);
- Structure* structure = JSInjectedScriptHost::createStructure(exec->vm(), globalObject, prototype);
- JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, impl);
-
- return injectedScriptHost;
-}
-
-JSInjectedScriptHost* toJSInjectedScriptHost(JSValue value)
-{
- return value.inherits(JSInjectedScriptHost::info()) ? jsCast<JSInjectedScriptHost*>(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 "JSDestructibleObject.h"
</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& vm, JSC::Structure* structure, PassRefPtr<InjectedScriptHost> impl)
</del><ins>+ static JSInjectedScriptHost* create(JSC::VM& vm, JSC::Structure* structure, Ref<InjectedScriptHost>&& impl)
</ins><span class="cx"> {
</span><del>- JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell<JSInjectedScriptHost>(vm.heap)) JSInjectedScriptHost(vm, structure, impl);
</del><ins>+ JSInjectedScriptHost* instance = new (NotNull, JSC::allocateCell<JSInjectedScriptHost>(vm.heap)) JSInjectedScriptHost(vm, structure, WTF::move(impl));
</ins><span class="cx"> instance->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&, JSC::JSGlobalObject*);
</span><span class="cx"> static void destroy(JSC::JSCell*);
</span><span class="cx">
</span><del>- InjectedScriptHost& impl() const { return *m_impl; }
- void releaseImpl();
</del><ins>+ InjectedScriptHost& impl() const { return const_cast<InjectedScriptHost&>(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&);
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- JSInjectedScriptHost(JSC::VM&, JSC::Structure*, PassRefPtr<InjectedScriptHost>);
- ~JSInjectedScriptHost();
</del><ins>+ JSInjectedScriptHost(JSC::VM&, JSC::Structure*, Ref<InjectedScriptHost>&&);
</ins><span class="cx">
</span><del>- InjectedScriptHost* m_impl;
</del><ins>+ Ref<InjectedScriptHost> 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 "config.h"
+#include "PerGlobalObjectWrapperWorld.h"
+
+using namespace JSC;
+
+namespace Inspector {
+
+JSValue PerGlobalObjectWrapperWorld::getWrapper(JSGlobalObject* globalObject)
+{
+ auto it = m_wrappers.find(globalObject);
+ if (it != m_wrappers.end())
+ return it->value.get();
+ return JSValue();
+}
+
+void PerGlobalObjectWrapperWorld::addWrapper(JSGlobalObject* globalObject, JSObject* object)
+{
+ Strong<JSObject> wrapper(globalObject->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 "JSCJSValueInlines.h"
+#include "Strong.h"
+#include "StrongInlines.h"
+#include <wtf/HashMap.h>
+
+namespace Inspector {
+
+class JS_EXPORT_PRIVATE PerGlobalObjectWrapperWorld {
+public:
+ JSC::JSValue getWrapper(JSC::JSGlobalObject*);
+ void addWrapper(JSC::JSGlobalObject*, JSC::JSObject*);
+ void clearAllWrappers();
+
+private:
+ HashMap<JSC::JSGlobalObject*, JSC::Strong<JSC::JSObject>> 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 <matthew_hanson@apple.com>
+
+ Merge r192186. rdar://problem/24101174
+
+ 2015-11-09 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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 <timothy@apple.com>
</span><span class="cx">
</span><span class="cx"> <rdar://problem/24094651> 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 <JavaScriptCore/PerGlobalObjectWrapperWorld.h>
+#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"> <ClInclude Include="..\ForwardingHeaders\inspector\InspectorProtocolObjects.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\InspectorProtocolTypes.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\InspectorValues.h" />
</span><ins>+ <ClInclude Include="..\ForwardingHeaders\inspector\PerGlobalObjectWrapperWorld.h" />
</ins><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\ScriptArguments.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\ScriptBreakpoint.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\ScriptCallFrame.h" />
</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"> <ClInclude Include="..\ForwardingHeaders\inspector\InspectorValues.h">
</span><span class="cx"> <Filter>ForwardingHeaders\inspector</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\ForwardingHeaders\inspector\PerGlobalObjectWrapperWorld.h">
+ <Filter>ForwardingHeaders\inspector</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\ForwardingHeaders\inspector\ScriptArguments.h">
</span><span class="cx"> <Filter>ForwardingHeaders\inspector</Filter>
</span><span class="cx"> </ClInclude>
</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 "CommandLineAPIHost.h"
</span><span class="cx">
</span><span class="cx"> #include "Database.h"
</span><del>-#include "Element.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLFrameOwnerElement.h"
</del><span class="cx"> #include "InspectorClient.h"
</span><span class="cx"> #include "InspectorDOMAgent.h"
</span><span class="cx"> #include "InspectorDOMStorageAgent.h"
</span><span class="cx"> #include "InspectorDatabaseAgent.h"
</span><del>-#include <inspector/InspectorFrontendDispatchers.h>
</del><ins>+#include "JSCommandLineAPIHost.h"
+#include "JSDOMGlobalObject.h"
</ins><span class="cx"> #include "Pasteboard.h"
</span><span class="cx"> #include "Storage.h"
</span><del>-#include "markup.h"
</del><span class="cx"> #include <bindings/ScriptValue.h>
</span><span class="cx"> #include <inspector/InspectorValues.h>
</span><span class="cx"> #include <inspector/agents/InspectorAgent.h>
</span><span class="cx"> #include <inspector/agents/InspectorConsoleAgent.h>
</span><ins>+#include <runtime/JSCInlines.h>
</ins><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</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<InspectableObject>())
</ins><span class="cx"> {
</span><del>- m_inspectedObject = std::make_unique<InspectableObject>();
</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->vm(), globalObject);
+ Structure* structure = JSCommandLineAPIHost::createStructure(exec->vm(), globalObject, prototype);
+ JSCommandLineAPIHost* commandLineAPIHost = JSCommandLineAPIHost::create(structure, globalObject, Ref<CommandLineAPIHost>(*this));
+ m_wrappers.addWrapper(globalObject, commandLineAPIHost);
+
+ return commandLineAPIHost;
+}
+
+void CommandLineAPIHost::clearAllWrappers()
+{
+ m_wrappers.clearAllWrappers();
+ m_inspectedObject = std::make_unique<InspectableObject>();
+}
+
</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 "ScriptState.h"
</span><del>-#include <runtime/ConsoleTypes.h>
</del><ins>+#include <inspector/PerGlobalObjectWrapperWorld.h>
</ins><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</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<InspectableObject> 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 "CommandLineAPIModule.h"
</span><span class="cx">
</span><span class="cx"> #include "CommandLineAPIModuleSource.h"
</span><del>-#include "DOMWrapperWorld.h"
-#include "JSCommandLineAPIHost.h"
</del><ins>+#include "JSDOMGlobalObject.h"
</ins><span class="cx"> #include "WebInjectedScriptManager.h"
</span><span class="cx"> #include <inspector/InjectedScript.h>
</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<WebInjectedScriptManager*>(injectedScriptManager);
</span><span class="cx"> ASSERT(pageInjectedScriptManager->commandLineAPIHost());
</span><ins>+
</ins><span class="cx"> JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
</span><del>- return toJS(exec, globalObject, pageInjectedScriptManager->commandLineAPIHost());
</del><ins>+ return pageInjectedScriptManager->commandLineAPIHost()->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->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>