Closed Bug 373261 Opened 17 years ago Closed 16 years ago

XPCOM error thrown when onsubmit handler called via setTimeout

Categories

(Core :: XPConnect, defect, P1)

PowerPC
macOS
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: Dolske, Unassigned)

Details

Attachments

(1 file)

A test case I was writing for password manager basically did the following:

window.addEventListener("submit", someFunction, false);
setTimeout(form.submit, 50);

The following error is thrown, showing up in the Error Console. |someFunction| never seems to be called.

Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object"  nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)"  location: "native frame :: <unknown filename> :: <TOP_LEVEL> :: line 0"  data: no]
Testcase to demonstrate bug. Just load, and it will alert() with pass/fail. [And you can see the error in the Error Console.]

Bonus points: It's Mochitest ready! (With minor pre-commented edits)
No longer blocks: 373253
"MacOSX Darwin 8.8.4 qm-xserve01 dep unit test" fails with this same error constantly.

*** 11665 ERROR FAIL | Error thrown during test: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object"  nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)"  location: "JS frame :: http://localhost:8888/tests/docshell/test/navigation/NavigationUtils.js :: searchForFinishedFrames :: line 207"  data: no] | got 0, expected 1 | /tests/docshell/test/navigation/test_reserved.html
Flags: blocking1.9?
Priority: -- → P1
Version: 1.8 Branch → unspecified
(In reply to comment #2)
> "MacOSX Darwin 8.8.4 qm-xserve01 dep unit test" fails with this same error
> constantly.

philor filed bug 416622 on this issue, so it may not be this bug, but I'm leaving this as blocking? until I hear otherwise.
(In reply to comment #0)
> A test case I was writing for password manager basically did the following:
> 
> window.addEventListener("submit", someFunction, false);
> setTimeout(form.submit, 50);

Functions exposed by xpconnect need their 'this' object at the time of the call, so this won't work. As sad as it may seem, this is per design and unlikely to change anytime soon. Moz2 maybe, but not before that. Marking WONTFIX as for now, this is per design.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
This reason this fails is that you're basically doing

foo = form.submit;
foo();

This will call the submit function, but the 'this' pointer won't be the correct form.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: