Title: [135765] trunk
- Revision
- 135765
- Author
- commit-qu...@webkit.org
- Date
- 2012-11-26 14:24:31 -0800 (Mon, 26 Nov 2012)
Log Message
Refactor V8 bindings to allow content scripts to access subframes
https://bugs.webkit.org/show_bug.cgi?id=93646
Patch by Dan Carney <dcar...@google.com> on 2012-11-26
Reviewed by Adam Barth.
Source/WebCore:
Isolated window shells are now initialized on the fly
as needed.
No new tests. Existing test modified.
* bindings/v8/DOMWrapperWorld.cpp:
(WebCore::DOMWrapperWorld::ensureIsolatedWorld):
* bindings/v8/DOMWrapperWorld.h:
(WebCore::DOMWrapperWorld::createdFromUnitializedWorld):
(DOMWrapperWorld):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::currentWorldContext):
LayoutTests:
Test modified to check isolated world access across frames.
* http/tests/security/isolatedWorld/world-reuse-expected.txt:
* http/tests/security/isolatedWorld/world-reuse.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (135764 => 135765)
--- trunk/LayoutTests/ChangeLog 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/LayoutTests/ChangeLog 2012-11-26 22:24:31 UTC (rev 135765)
@@ -1,3 +1,15 @@
+2012-11-26 Dan Carney <dcar...@google.com>
+
+ Refactor V8 bindings to allow content scripts to access subframes
+ https://bugs.webkit.org/show_bug.cgi?id=93646
+
+ Reviewed by Adam Barth.
+
+ Test modified to check isolated world access across frames.
+
+ * http/tests/security/isolatedWorld/world-reuse-expected.txt:
+ * http/tests/security/isolatedWorld/world-reuse.html:
+
2012-11-26 Tony Chang <t...@chromium.org>
Move more functions from internals.settings to internals
Modified: trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse-expected.txt (135764 => 135765)
--- trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse-expected.txt 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse-expected.txt 2012-11-26 22:24:31 UTC (rev 135765)
@@ -2,6 +2,8 @@
Expecting undefined: undefined
Expecting bar: bar
Expecting undefined: undefined
+Expecting true: true
+Expecting true: true
Expecting undefined,undefined: undefined,undefined
Expecting undefined,undefined: undefined,undefined
Modified: trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse.html (135764 => 135765)
--- trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse.html 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/LayoutTests/http/tests/security/isolatedWorld/world-reuse.html 2012-11-26 22:24:31 UTC (rev 135765)
@@ -30,10 +30,22 @@
document.body.insertBefore(iframe, document.body.firstChild);
document.body.insertBefore(document.createElement("br"), iframe.nextSibling);
var iframeComplete = function(result) {
+
+ // Isolated world executing in frame should be able to to access parent content.
+ testRunner.evaluateScriptInIsolatedWorld(1,
+ "parent.document.body.appendChild(parent.document.createTextNode('Expecting true: ' + (parent.frames[0].document == this.document)));" +
+ "parent.document.body.appendChild(parent.document.createElement('br'));");
+
document.body.appendChild(document.createTextNode('Expecting undefined,undefined: ' + result));
document.body.appendChild(document.createElement('br'));
reloadFrame();
}
+
+ // Isolated world executing in window should be able to to access frame content.
+ testRunner.evaluateScriptInIsolatedWorld(1,
+ "document.body.appendChild(document.createTextNode('Expecting true: ' + !!frames[0].document));" +
+ "document.body.appendChild(document.createElement('br'));");
+
iframe.src = ""
// Also, navigating a single frame should not result in sharing variables.
Modified: trunk/Source/WebCore/ChangeLog (135764 => 135765)
--- trunk/Source/WebCore/ChangeLog 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/Source/WebCore/ChangeLog 2012-11-26 22:24:31 UTC (rev 135765)
@@ -1,3 +1,23 @@
+2012-11-26 Dan Carney <dcar...@google.com>
+
+ Refactor V8 bindings to allow content scripts to access subframes
+ https://bugs.webkit.org/show_bug.cgi?id=93646
+
+ Reviewed by Adam Barth.
+
+ Isolated window shells are now initialized on the fly
+ as needed.
+
+ No new tests. Existing test modified.
+
+ * bindings/v8/DOMWrapperWorld.cpp:
+ (WebCore::DOMWrapperWorld::ensureIsolatedWorld):
+ * bindings/v8/DOMWrapperWorld.h:
+ (WebCore::DOMWrapperWorld::createdFromUnitializedWorld):
+ (DOMWrapperWorld):
+ * bindings/v8/ScriptController.cpp:
+ (WebCore::ScriptController::currentWorldContext):
+
2012-11-26 Alex Christensen <alex.christen...@flexsim.com>
clipboardwin compile error for win64
Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp (135764 => 135765)
--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp 2012-11-26 22:24:31 UTC (rev 135765)
@@ -137,6 +137,7 @@
PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::ensureIsolatedWorld(int worldId, int extensionGroup)
{
ASSERT(worldId != mainWorldId);
+ ASSERT(worldId >= uninitializedWorldId);
WorldMap& map = isolatedWorldMap();
if (worldId == uninitializedWorldId)
Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h (135764 => 135765)
--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h 2012-11-26 22:24:31 UTC (rev 135765)
@@ -96,6 +96,8 @@
bool isMainWorld() const { return m_worldId == mainWorldId; }
bool isIsolatedWorld() const { return isIsolatedWorldId(m_worldId); }
+ bool createdFromUnitializedWorld() const { return m_worldId < uninitializedWorldId; }
+
int worldId() const { return m_worldId; }
int extensionGroup() const { return m_extensionGroup; }
DOMDataStore* isolatedWorldDOMDataStore() const
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (135764 => 135765)
--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2012-11-26 22:15:06 UTC (rev 135764)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2012-11-26 22:24:31 UTC (rev 135765)
@@ -436,15 +436,26 @@
v8::Local<v8::Context> ScriptController::currentWorldContext()
{
- if (v8::Context::InContext()) {
- v8::Handle<v8::Context> context = v8::Context::GetEntered();
- if (DOMWrapperWorld::isolated(context)) {
- if (m_frame == toFrameIfNotDetached(context))
- return v8::Local<v8::Context>::New(context);
- return v8::Local<v8::Context>();
- }
- }
- return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+ if (!v8::Context::InContext())
+ return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+
+ v8::Handle<v8::Context> context = v8::Context::GetEntered();
+ DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolated(context);
+ if (!isolatedWorld)
+ return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+
+ Frame* frame = toFrameIfNotDetached(context);
+ if (!m_frame)
+ return v8::Local<v8::Context>();
+
+ if (m_frame == frame)
+ return v8::Local<v8::Context>::New(context);
+
+ // FIXME: Need to handle weak isolated worlds correctly.
+ if (isolatedWorld->createdFromUnitializedWorld())
+ return v8::Local<v8::Context>();
+
+ return v8::Local<v8::Context>::New(windowShell(isolatedWorld)->context());
}
v8::Local<v8::Context> ScriptController::mainWorldContext()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes