Closed
Bug 506293
Opened 17 years ago
Closed 15 years ago
SetTimout does not input.select NS_ERROR_XPC_BAD_OP_ON_WN_PROTO
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
INVALID
People
(Reporter: leolite1, Unassigned)
Details
(Keywords: testcase)
Attachments
(1 file)
|
253 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)
When using setTimeout to select an input field the call fails unless there is a extra "()" which doesn't make sense since the () indicate the execution of the function right away.
function handler(){document.getElementById("field1").select();}
setTimeout(handler, 200); //works
setTimeout(document.getElementById("field1").select, 200); //doesn't work
setTimeout('document.getElementById("field1").select()', 200); //works
The failed case gives the NS_ERROR_XPC_BAD_OP_ON_WN_PROTO exception
Reproducible: Always
Steps to Reproduce:
See Details
Actual Results:
Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "<unknown>" data: no]
Expected Results:
The callback should be triggered as defined in the Mozilla setTimeout documentation.
This is my sample test page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>setTimeout</title>
<script type="text/javascript">
function handler(){ document.getElementById("field1").select(); }
function process()
{
//setTimeout('document.getElementById("field1").select()', 200); //works
//setTimeout(Core.handler, 200); //works
setTimeout(document.getElementById("field1").select, 200); //doesn't work
}
</script>
</head>
<body>
<button type="submit" onclick="process();">setTimeout</button>
<input id="field1" type="text" value="text" />
</body>
</html>
Comment 2•15 years ago
|
||
Comment 3•15 years ago
|
||
On first sight, looks like this happens with all native methods.
Assignee: nobody → general
Severity: major → normal
Status: UNCONFIRMED → NEW
Component: General → JavaScript Engine
Ever confirmed: true
Keywords: testcase
OS: Windows Vista → All
Product: Firefox → Core
QA Contact: general → general
Hardware: x86 → All
Version: 3.5 Branch → Trunk
Comment 4•15 years ago
|
||
This is the right behavior. setTimeout runs its first argument with the |this| object set to the window. So you're trying to do, basically:
document.getElementById("field1").select.call(window);
The |select| method has no idea what to do with a |this| that's a Window; it only knows what to do with an HTMLInputElement |this|. So it throws. What were you expecting this code to do, exactly? If the idea was to select the field after a timeout, then your "handler" approach is the right way to do that.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Comment 5•15 years ago
|
||
And another note: NONE of this involves the JS engine. This is all DOM/XPConnect stuff.
Assignee: general → nobody
Component: JavaScript Engine → DOM
QA Contact: general → general
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•