Closed
Bug 12433
Opened 25 years ago
Closed 25 years ago
Javascript OnClick handler does not work from a xul file
Categories
(Core :: Layout, defect, P3)
Tracking
()
VERIFIED
WORKSFORME
M10
People
(Reporter: morse, Assigned: joki)
References
Details
Copy the content below into the two files called x.xul and x.js. Bring up x.xul in the browser window. Click on the text that says "Click here". You get an assertion failure (debug builds only) but we already know about that (see bug 10441). Continue execution from the failure. The word "Thanks" is supposed to appear but it does not -- instead the "Click here" text remains on the screen. This works correctly from an html file as shown in bug 12432 (but it had other problems). Here are the files: 1. x.xul: <?xml version="1.0"?> <!DOCTYPE window> <xul:window xmlns="http://www.w3.org/TR/REC-html40" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script src="x.js"/> <frameset rows = "20,10" onload="load1();"> <frame src="about:blank"/> <frame src="about:blank"/> </frameset> </xul:window> 2. x.js: function load1(){ top.frames[0].document.open(); top.frames[0].document.write( "<a onclick='top.load2();' href=''>Click here</a>" ); top.frames[0].document.close(); } function load2(){ top.frames[0].document.open(); top.frames[0].document.write( "Thanks" ); top.frames[0].document.close(); }
Updated•25 years ago
|
Severity: normal → blocker
Comment 1•25 years ago
|
||
Nisheeth, this bug is blocking our development.
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M10
Comment 2•25 years ago
|
||
Setting status to assigned and target milestone to M10. I'll take a look at this today.
Updated•25 years ago
|
Assignee: nisheeth → joki
Status: ASSIGNED → NEW
Comment 3•25 years ago
|
||
OK, after much poking around in DOM event handling land, here's what I've found. The load1() function does a document.write of the <a onclick='top.load2();' href=''> tag after x.xul loads. nsGenericHTMLElement::SetAttribute() processes the attributes on the <a> tag, sees the onclick handler and calls nsGenericElement::AddScriptEventListener(). This method calls the event listener manager's AddScriptEventListener() method. Inside nsEventListenerManager::AddScriptEventListener() (snippet is pasted below), the GetPrincipal() method fails and we abort out of the method without adding any event listener for the onclick event. if (global && NS_SUCCEEDED(global->QueryInterface(kIScriptGlobalObjectDataIID, (void**)&globalData))) { if (NS_FAILED(globalData->GetPrincipal(& prin))) { NS_RELEASE(global); NS_RELEASE(globalData); return NS_ERROR_FAILURE; } prin->ToJSPrincipal(& jsprin); NS_RELEASE(globalData); } I'm assigning this to Tom Pixley, the events god for further debugging.
Assignee | ||
Comment 5•25 years ago
|
||
Okay, is it just me or did this fix itself? I was going to fix it but suddenly found it working. Mind you we hit an error in nsHTTPChannel::Open() immediately afterwards but the 'Thanks' shows up so it would seem the handler is being registered. I'll let someone who has seen the behavior before verify this before I mark it fixed.
Reporter | ||
Updated•25 years ago
|
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 6•25 years ago
|
||
Yes, it is working properly now. Thanks, joki, you have the magic touch. I'll mark it closed. With this fixed, I was now able to finish the conversion of my htlm viewers to xul and they are all working fine. I'm unblocked.
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Comment 7•25 years ago
|
||
In the Sept 2nd , its working for me as weel.
Comment 8•25 years ago
|
||
In the Sept 2nd , its working for me as well.
Comment hidden (collapsed) |
You need to log in
before you can comment on or make changes to this bug.
Description
•