Closed
Bug 918884
Opened 11 years ago
Closed 11 years ago
Implement a method to get the DOM element that owns a docshell
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla27
People
(Reporter: paul, Assigned: bgrins)
Details
Attachments
(1 file, 2 obsolete files)
8.56 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
With the DOM, we can do window.frameElement. It would be convenient to have a similar method from the docshell. Here is how we do in JavaScript for the devtools: http://mxr.mozilla.org/mozilla-aurora/source/toolkit/devtools/LayoutHelpers.jsm#370
Reporter | ||
Comment 1•11 years ago
|
||
And for the devtools, this needs to cross the mozbrowser and mozapp iframes.
Comment 2•11 years ago
|
||
So for a toplevel content docshell, should this return null or the <xul:browser> in question?
Reporter | ||
Comment 3•11 years ago
|
||
The <xul:browser> if that's possible.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → bgrinstead
Assignee | ||
Comment 4•11 years ago
|
||
This patch implements a GetContainer method to return the result of GetFrameElementInternal, and adds a test for iframes and objects in devtools. Let me know how many things I've done wrong :). A couple of questions: 1) Right now, the test fails for the top level window (it is returning the window object instead of the xul element). The others work, returning the proper [object HTMLIFrameElement] or [object HTMLObjectElement]. Any ideas for how to return the <xul:browser> as in pointed out in Comment 3? Here is the error message: > ./mach mochitest-browser browser/devtools/inspector/test/browser_inspector_frames.js > Container element for main window is xul:browser - Got [object XrayWrapper [object Window]], expected [object XULElement] 2) Should I move the test somewhere else (into dom/tests somewhere)?
Attachment #808794 -
Flags: feedback?(gavin.sharp)
Comment 5•11 years ago
|
||
Comment on attachment 808794 [details] [diff] [review] getcontainer-wip.patch Looks great! This should probably actually be a readonly attribute rather than a method - not sure why I suggested otherwise earlier. Should just be a matter of changing the IDL accordingly. You'll need to add a security check (as in the other methods, see also bug 775868) lest this be abused by content code. The comment in the IDL should probably be improved. You could describe it as "this window's frame element" without mentioning the docShell, since that actually isn't involved here, and you should probably also mention that this completely ignores all chrome/content or mozbrowser boundaries, rather than mentioning the specific example of the "top level content docshell". bz may have additional feedback or concerns.
Attachment #808794 -
Flags: feedback?(gavin.sharp)
Attachment #808794 -
Flags: feedback?(bzbarsky)
Attachment #808794 -
Flags: feedback+
Comment 6•11 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #4) Oh sorry, missed this comment. > 1) Right now, the test fails for the top level window (it is returning the > window object instead of the xul element). The others work, returning the > proper [object HTMLIFrameElement] or [object HTMLObjectElement]. Any ideas > for how to return the <xul:browser> as in pointed out in Comment 3? Here is > the error message: > > ./mach mochitest-browser > browser/devtools/inspector/test/browser_inspector_frames.js > > Container element for main window is xul:browser - Got [object > XrayWrapper [object Window]], expected [object XULElement] Hmm, interesting. I'm not sure why this would be, offhand, maybe bz knows. > 2) Should I move the test somewhere else (into dom/tests somewhere)? The existing test is good, but there should probably also be a test that is devtools-agnostic somewhere under dom (e.g. dom/tests/browser/), which only tests the getter without any dependencies on devtools.
Assignee | ||
Comment 7•11 years ago
|
||
(In reply to :Gavin Sharp (use gavin@gavinsharp.com for email) from comment #6) OK, thanks for the feedback, I will rebuild a patch with the changes. > (In reply to Brian Grinstead [:bgrins] from comment #4) > > Oh sorry, missed this comment. > > > 1) Right now, the test fails for the top level window (it is returning the > > window object instead of the xul element). The others work, returning the > > proper [object HTMLIFrameElement] or [object HTMLObjectElement]. Any ideas > > for how to return the <xul:browser> as in pointed out in Comment 3? Here is > > the error message: > > > ./mach mochitest-browser > > browser/devtools/inspector/test/browser_inspector_frames.js > > > Container element for main window is xul:browser - Got [object > > XrayWrapper [object Window]], expected [object XULElement] > > Hmm, interesting. I'm not sure why this would be, offhand, maybe bz knows. > Oops, nevermind about question (1) - this was caused by a typo on my part.
Assignee | ||
Comment 8•11 years ago
|
||
* Made GetContainerElement a readonly attribute rather than a getter. * Updated comment in idl (may need to be more clear still) * Added dom/tests/browser/browser_frame_element.js test to remove the dependency on devtools in testing. This test is all green. If there are any other elements worth testing (that can be a frame element) I can add them to the test. I may actually remove the devtools tests here and instead modify the case in Bug 917448.
Attachment #808794 -
Attachment is obsolete: true
Attachment #808794 -
Flags: feedback?(bzbarsky)
Assignee | ||
Comment 9•11 years ago
|
||
Comment on attachment 808816 [details] [diff] [review] getcontainer-wip1.patch > bz may have additional feedback or concerns.
Attachment #808816 -
Flags: feedback?(bzbarsky)
Comment 10•11 years ago
|
||
Comment on attachment 808816 [details] [diff] [review] getcontainer-wip1.patch >+ CallQueryInterface(element, aResult); This will crash with a null-deref if you call this on a toplevel window. Better to do: element.forget(aResult); f+=me with that.
Attachment #808816 -
Flags: feedback?(bzbarsky) → feedback+
Assignee | ||
Comment 11•11 years ago
|
||
Expanded the test case to include an iframe with the mozbrowser attribute set. Changed to `element.forget(aResult);` as suggested by bz. Pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=dd8a633e5e12.
Attachment #808816 -
Attachment is obsolete: true
Attachment #809231 -
Flags: review?(bzbarsky)
Comment 12•11 years ago
|
||
Comment on attachment 809231 [details] [diff] [review] getcontainer.patch r=me
Attachment #809231 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 13•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/ab3635da717e
Flags: in-testsuite+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/ab3635da717e
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•