WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
93646
Refactor V8 bindings to allow content scripts to access subframes
https://bugs.webkit.org/show_bug.cgi?id=93646
Summary
Refactor V8 bindings to allow content scripts to access subframes
Dan Carney
Reported
2012-08-09 13:27:58 PDT
see
http://code.google.com/p/chromium/issues/detail?id=20773
Attachments
initial patch to show direction of change
(28.69 KB, patch)
2012-08-09 13:29 PDT
,
Dan Carney
no flags
Details
Formatted Diff
Diff
mostly the same as first patch rebased after V8PerContextData rename
(29.77 KB, patch)
2012-08-10 03:21 PDT
,
Dan Carney
no flags
Details
Formatted Diff
Diff
Patch
(66.63 KB, patch)
2012-08-27 04:35 PDT
,
Dan Carney
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from gce-cr-linux-01
(1.68 MB, application/zip)
2012-08-27 05:11 PDT
,
WebKit Review Bot
no flags
Details
Patch
(7.10 KB, patch)
2012-11-26 04:01 PST
,
Dan Carney
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Dan Carney
Comment 1
2012-08-09 13:29:05 PDT
Created
attachment 157527
[details]
initial patch to show direction of change
Dan Carney
Comment 2
2012-08-09 13:34:07 PDT
Comment on
attachment 157527
[details]
initial patch to show direction of change this patch works in the sense that it compiles and the example extension in
http://code.google.com/p/chromium/issues/detail?id=20773
works. It's nowhere near cleaned up though, and I've probably introduced some memory leaks.
Dan Carney
Comment 3
2012-08-10 03:21:48 PDT
Created
attachment 157696
[details]
mostly the same as first patch rebased after V8PerContextData rename
Dan Carney
Comment 4
2012-08-27 04:35:04 PDT
Created
attachment 160690
[details]
Patch
WebKit Review Bot
Comment 5
2012-08-27 05:11:41 PDT
Comment on
attachment 160690
[details]
Patch
Attachment 160690
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13616143
New failing tests: http/tests/appcache/different-origin-manifest.html accessibility/aria-checkbox-checked.html accessibility/aria-labelledby-on-input.html http/tests/appcache/document-write-html-element.html animations/3d/matrix-transform-type-animation.html accessibility/aria-readonly.html http/tests/appcache/cyrillic-uri.html accessibility/canvas-fallback-content.html animations/animation-add-events-in-handler.html http/tests/appcache/deferred-events-delete-while-raising.html accessibility/accessibility-node-reparent.html http/tests/appcache/fail-on-update-2.html animations/animation-direction-alternate-reverse.html http/tests/appcache/access-via-redirect.php accessibility/aria-hidden.html http/tests/appcache/destroyed-frame.html http/tests/appcache/disabled.html animations/animation-controller-drt-api.html animations/3d/transform-perspective.html accessibility/aria-scrollbar-role.html http/tests/appcache/crash-when-navigating-away-then-back.html canvas/philip/tests/2d.canvas.reference.html animations/3d/state-at-end-event-transform.html accessibility/aria-labelledby-stay-within.html animations/animation-direction-reverse-hardware.html accessibility/aria-help.html animations/animation-direction-reverse-fill-mode.html accessibility/adjacent-continuations-cause-assertion-failure.html animations/animation-direction-reverse-timing-functions-hardware.html canvas/philip/tests/2d.clearRect+fillRect.alpha0.html
WebKit Review Bot
Comment 6
2012-08-27 05:11:46 PDT
Created
attachment 160694
[details]
Archive of layout-test-results from gce-cr-linux-01 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: gce-cr-linux-01 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Adam Barth
Comment 7
2012-08-27 11:45:27 PDT
Comment on
attachment 160690
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=160690&action=review
Looks like you have some test failures. This patch looks very promising. I need to study it in more detail. Is it possible to make this change in smaller steps? There's a lot to digest in this patch.
> Source/WebCore/bindings/v8/DOMWrapperWorld.cpp:69 > + v8::Persistent<v8::Context> localCopy = v8::Persistent<v8::Context>::New(context);
Can we store this Persistent handle as a ScopedPersistent on DOMWrapperWorld?
Adam Barth
Comment 8
2012-08-27 11:55:55 PDT
Comment on
attachment 160690
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=160690&action=review
> Source/WebCore/bindings/v8/ScriptController.cpp:338 > + m_isolatedWorlds.set(worldId, isolatedWorldShell.get());
Can we key m_isolatedWorlds off of DOMWrapperWorld rather than worldId? I'd like to remove the concept of worldId from WebCore eventually and have that just be a concern of the WebKit-layer (i.e., code in Source/WebKit/chromium).
> Source/WebCore/bindings/v8/ScriptController.cpp:443 > + isolatedShell = windowShell(isolatedShell->world()); > + // FIXME: need to set security token here > + isolatedShell->initContextIfNeeded();
For example, this work can be in a separate patch. This is a big behavior change, and it would be nice to make that change separately from all the refactorings that make it possible.
> Source/WebCore/bindings/v8/ScriptController.h:69 > V8DOMWindowShell* windowShell() const { return m_windowShell.get(); }
We probably want to delete this function and have all the callers use windowShell(mainWold()) or whatever.
> Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:90 > +static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> context) > +{ > + return v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype()); > +}
getGlobalObject is a bit of a misnomer. How about toInnerGlobalObject(v8::Handle<v8::Context>)
> Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:97 > +V8DOMWindowShell* V8DOMWindowShell::isolatedWorldContext()
This function should have the term "entered" in its name somewhere because it's calling v8::Context::GetEntered
> Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:220 > + : m_frame(frame), > + m_world(world),
These commas go on the next line under the ":". See Other Punctuation in
http://www.webkit.org/coding/coding-style.html
> Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:298 > +static void isolatedContextWeakCallback(v8::Persistent<v8::Value> object, void* parameter) > +{ > + object.Dispose(); > + reinterpret_cast<V8DOMWindowShell*>(parameter)->deref(); > +} > + > +static void registerWeakHandler(v8::Handle<v8::Context> context, V8DOMWindowShell* shell) > +{ > + v8::Persistent<v8::Context>::New(context).MakeWeak(shell, isolatedContextWeakCallback); > + shell->ref(); > +}
Can we hold this Persistent handle as a ScopedPersistent on V8DOMWindowShell ? Doesn't it already have a ScopedPersistent to a v8::Context?
Dan Carney
Comment 9
2012-09-04 05:09:33 PDT
(In reply to
comment #7
)
> (From update of
attachment 160690
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=160690&action=review
> > Looks like you have some test failures. This patch looks very promising. I need to study it in more detail. > > Is it possible to make this change in smaller steps? There's a lot to digest in this patch.
It's not so easy. There are lots of refactors after this that need to be done, but they all assume the isolated context is gone, and I'm not sure I can really do that in multiple steps. I moved the patch to
https://bugs.webkit.org/show_bug.cgi?id=95735
since it no longer fixes this issue.
Dan Carney
Comment 10
2012-11-26 04:01:20 PST
Created
attachment 175963
[details]
Patch
Dan Carney
Comment 11
2012-11-26 04:19:43 PST
Comment on
attachment 175963
[details]
Patch This patch currently handles all user scripts except those injected by WebView.addUserScript, which I believe may just be apps, but I'm not sure. All extensions that I invent seem to work correctly.
Adam Barth
Comment 12
2012-11-26 09:39:05 PST
That's great! I will study the patch carefully. Does this mean
http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp#L85
is now called multiple times per DOMWrapperWorld, based on the number of Frames that the world gets booted up in? If you've already gone to sleep, I can puzzle that out for myself.
Dan Carney
Comment 13
2012-11-26 09:47:04 PST
(In reply to
comment #12
)
> That's great! I will study the patch carefully. > > Does this mean
http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp#L85
is now called multiple times per DOMWrapperWorld, based on the number of Frames that the world gets booted up in? If you've already gone to sleep, I can puzzle that out for myself.
it's pretty early to go to sleep. i'll explain: i've avoided dealing with the types of worlds that have called makeContextWeak in this patch, so they don't have cross frame access yet. I'll deal with that in a different patch. I wanted to confer with you on that first. We have 2 options: get rid of the weak contexts which could mean a lot more mem consumption for whatever actually uses them do a complicated thing where the a new hidden object in javascript that represents the DOMWrapperWorld has a weak handle on the context and the context a weak handle on the world js object so that they all die at once I'm inclined to do the second, but it would be a lot easier just to remove a few lines of code than do a bunch of v8 api magic to make this work wdyt?
Dan Carney
Comment 14
2012-11-26 09:49:14 PST
Comment on
attachment 175963
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175963&action=review
> Source/WebCore/bindings/v8/ScriptController.cpp:459 > + // FIXME: Need to handle weak isolated worlds correctly.
This is where i explicit stop the weak contexts from being accessible. Otherwise the frame context or it's parent could die in background and would be reinit'ed with an new window context which would be bad.
Adam Barth
Comment 15
2012-11-26 11:08:50 PST
Comment on
attachment 175963
[details]
Patch This patch is great and exactly how I'd hoped we'd be able to implement this feature. My only real comment is stylistic. I'd add a helper function align the lines of inline v8::Local<v8::Context> ScriptController::contextForWorld(DOMWrapperWorld* world) { return v8::Local<v8::Context>::New(windowShell(world)->context()); } since you use that idiom a bunch. Once this rolls into Chromium, would you be willing to add extension API test so we can test the integration with the extension system?
Dan Carney
Comment 16
2012-11-26 12:27:36 PST
(In reply to
comment #15
)
> (From update of
attachment 175963
[details]
) > This patch is great and exactly how I'd hoped we'd be able to implement this feature. > > My only real comment is stylistic. I'd add a helper function align the lines of > > inline v8::Local<v8::Context> ScriptController::contextForWorld(DOMWrapperWorld* world) > { > return v8::Local<v8::Context>::New(windowShell(world)->context()); > }
Okay, will add. I was inlining those since i figured the first couple branches at least got hit a lot in the perf tests.
> > since you use that idiom a bunch. > > Once this rolls into Chromium, would you be willing to add extension API test so we can test the integration with the extension system?
sure. i've put it on my todo list.
Adam Barth
Comment 17
2012-11-26 12:35:41 PST
> Okay, will add. I was inlining those since i figured the first couple branches at least got hit a lot in the perf tests.
You can ask the compiler to inline it rather than doing it manually.
Dan Carney
Comment 18
2012-11-26 12:50:59 PST
Comment on
attachment 175963
[details]
Patch I'll add that inline change tomorrow, to avoid the timezone wait.
Adam Barth
Comment 19
2012-11-26 14:04:00 PST
Comment on
attachment 175963
[details]
Patch Thanks.
WebKit Review Bot
Comment 20
2012-11-26 14:25:18 PST
Comment on
attachment 175963
[details]
Patch Clearing flags on attachment: 175963 Committed
r135765
: <
http://trac.webkit.org/changeset/135765
>
WebKit Review Bot
Comment 21
2012-11-26 14:25:24 PST
All reviewed patches have been landed. Closing bug.
Roger Fong
Comment 22
2012-11-26 18:20:02 PST
http://build.webkit.org/results/Apple%20MountainLion%20Release%20WK1%20(Tests)/r135791%20(4011)/results.html
http/tests/security/isolatedWorld/world-reuse.html failing on Apple Mac and Windows ports after this patch.
Adam Barth
Comment 23
2012-11-26 19:05:18 PST
We should probably update the baseline for now and then have Dan look at why it might be failing on JSC.
Dan Carney
Comment 24
2012-11-27 01:22:04 PST
(In reply to
comment #23
)
> We should probably update the baseline for now and then have Dan look at why it might be failing on JSC.
Looking into it
Dan Carney
Comment 25
2012-11-27 02:58:12 PST
(In reply to
comment #23
)
> We should probably update the baseline for now and then have Dan look at why it might be failing on JSC.
I've submitted a patch that fixes the test to pass on safari and chrome builds.
https://bugs.webkit.org/show_bug.cgi?id=103385
it looks like that if you run evaluateScriptInIsolatedWorld in safari, it's run in the main window's frame's context. If you do the same on chrome, it runs in the context of the current frame.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug