Closed Bug 138295 Opened 22 years ago Closed 22 years ago

XML Loading on Mac fails on .childNodes of non-root nodes

Categories

(Core :: DOM: Core & HTML, defect, P2)

PowerPC
All
defect

Tracking

()

RESOLVED FIXED
mozilla1.2alpha

People

(Reporter: andyed, Assigned: peterv)

References

()

Details

(Whiteboard: [adt2 RTM])

Attachments

(4 files, 3 obsolete files)

Expected behavior:
Text box contains 4 rolodex nodes (works on windows)

Observed behavior on Mac OS9/OSX:
Error: [Exception... "'Permission denied to get property NodeList.length' when
calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]
QA Contact: petersen → rakeshmishra
changing Q/A contact
This is bizarre, works on latest Windows mozilla build, but I get the error
using Mac OSX build from last week or something...

I don't think XML is the correct component, reassigning to DOM Core and adding
mstoltz as this is security related.
Assignee: heikki → jst
Component: XML → DOM Core
QA Contact: rakeshmishra → stummala
I've seen other failures like this one on OS 9 too.
We need to check this out, we can't ship if simple DOM operations won't work on
the Mac.

Could we get the testcase in normal HTML to see if it happens in XML only (doubt
it)?
Severity: normal → major
Keywords: nsbeta1
I'll craft a XML-free test case, but I've got XBL that loops over childNodes on 
the Mac successfully (http://surfmind.com/musings/categories/mozilla/).
ML free .childNodes iteration, works fine on Mac OS9.

This does seem to be an issue with XML load as opposed to general Mac DOM
operations.  Email me directly if there's a further testcase which would help.
Keywords: nsbeta1nsbeta1+
Whiteboard: [adt1]
Attached file Testcase (html file)
Ok, so when opening attachment 80932 [details] on Mac I get an exception "Permission
denied to get property NodeList.length", while on Windows and Linux accessing
.length just gives the right value (0). I have no idea what is going on here.
I'm adding the XPConnect folks too, right now I'm stuck and I could use some
hints on how to debug this.
Ok, so with dbradley's help I tracked this down a bit. It seems that the
security check to get .length fails in CheckSameOrigin. Mitch, any idea why this
would fail on Mac only?
Assignee: jst → mstoltz
We have similar problems when using code like:

var xpe = new XPathEvaluator();
var nsRes = xpe.createNSResolver(xmlNode); // Permission denied exception
var result = xpe.evaluate(xpath, xmlNode, 
                        null, null, null); // Permission denied exception

Maybe there is a problem with the eventhandler and is the xmlDoc not yet loaded?
Blocks: 143047
Whiteboard: [adt1] → [adt1 RTM]
What's the current status of this bug?  (No comments for a VERY long time...)
I'm looking at it now. ETA 6/20.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.0.1
Jst and I have debugged this and I have a patch almost ready.
What was the problem? And why did it only affect the Mac?
OK, sounds like peterv has a fix for the trunk, but it won't work for the branch
because it depends on some major API changes that have landed on the trunk
recently. jst thinks we can get by without this fix for Moz1.0.1, but I'm going
to reassign this to peterv and let him make the final call. If this is not a
stop-ship, please remove the nsbeta1+.
Assignee: mstoltz → peterv
Status: ASSIGNED → NEW
makring as nsbeta1-, and lowering ADT impact to ADT2 per Comment #16 From
Mitchell Stoltz. let's see if we can't get this on a future release.
Keywords: nsbeta1+nsbeta1-
Whiteboard: [adt1 RTM] → [adt2 RTM]
No longer blocks: 143047
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: mozilla1.0.1 → mozilla1.1beta
Attached patch Patch (obsolete) — Splinter Review
This fixes it for me. Not sure if there are other place where we need a similar
fix. The problem is that we were using the safe context when calling the event
handler and the safe context comes from the hidden window (and on Mac the
hidden window probably contains a document with a chrome URI).
Comment on attachment 88885 [details] [diff] [review]
Patch

nsContentUtils::GetDocshellFromGlobalObject needs to be renamed to something
like GetCurrentDOMWindow() and changed to return the DOM window off the current
JS context.
- In nsXMLDocument.cpp:

+    nsCOMPtr<nsIScriptGlobalObjectOwner> container =
+	 do_QueryReferent(mDocumentContainer);

Sigh, 4-space indentation! :-)

sr=jst if you fix that.
Attachment #88885 - Flags: superreview+
Attached patch Patch (obsolete) — Splinter Review
Updated to trunk and renamed method.
Attachment #88885 - Attachment is obsolete: true
Comment on attachment 91813 [details] [diff] [review]
Patch

Carrying forward jst's sr.
Attachment #91813 - Flags: superreview+
Comment on attachment 91813 [details] [diff] [review]
Patch

Would there be any performance benefit to keeping a reference to the
JSContextStack service across multiple iterations of this code?

r=mstoltz whether or not you do this.
Attachment #91813 - Flags: review+
Keywords: nsbeta1-nsbeta1+
Target Milestone: mozilla1.1beta → mozilla1.2alpha
Attached patch Patch (obsolete) — Splinter Review
Changed to cache context stack.
Attachment #91813 - Attachment is obsolete: true
Comment on attachment 94019 [details] [diff] [review]
Patch

Carrying forward r and sr.
Attachment #94019 - Flags: superreview+
Attachment #94019 - Flags: review+
There's now (as of a few weeks ago) an nsCxPusher class in
nsEventListenerManager.h, maybe you could move that to nsContentUtils and use
that in nsXMLDocument?

Either way, my sr= still stands.
Attached patch PatchSplinter Review
Attachment #94019 - Attachment is obsolete: true
Comment on attachment 94451 [details] [diff] [review]
Patch

- In nsXMLDocument.cpp:

+
+    nsCOMPtr<nsIJSContextStack> stack;
+    nsCOMPtr<nsIScriptGlobalObjectOwner> container =
+      do_QueryReferent(mDocumentContainer);
+
+    nsCxPusher pusher(container);
+
     HandleDOMEvent(nsnull, &event, nsnull, NS_EVENT_FLAG_INIT, &status);

I don't see stack being used anywhere, so remove that.

Other than that, sr=jst
Attachment #94451 - Flags: superreview+
Comment on attachment 94451 [details] [diff] [review]
Patch

Looks good to me. r=mstoltz.
Attachment #94451 - Flags: review+
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Can you reopen this bug, it seems to be back again.

I'm getting the same error again on MacOS X 10.3.6.  I'm getting this both in 
Firefox 1.0 and Mozilla 1.8.alpha5. The example provided for this bug, gives me: 
"Error: xmlDoc.childNodes.item(i) has no properties
Source File: http://surfmind.com/lab/moz/bugs/macxml/
Line: 28"

In my own code I still get the original childNodes.length error. And it seems to
be for nodes from level 2 and down. I have tested to create the DOM document
both thru document.load and XMLHTTPRequest, with the same result.
File a new bug if this regressed.
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: