hasOwnProperty on Events returns true only for "isTruested" property

RESOLVED INVALID

Status

()

Core
DOM: Events
RESOLVED INVALID
4 years ago
4 years ago

People

(Reporter: Taye A, Unassigned)

Tracking

32 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8432119 [details]
event-hasownprop-bug.txt

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20140531030204

Steps to reproduce:

On Nightly, code which would normally duplicate an event with a for...in loop and a hasOwnProperty check on each property doesn't work. Only "isTrusted" passes the check and is copied to the new object.

for example:

document.addEventListener('click', function (event) {
    var copy = {},
        pre = document.createElement('pre');

    for (var prop in event) {
        var hasOwn = event.hasOwnProperty(prop);

        if (hasOwn) {
            copy[prop] = event[prop];
        }
        pre.textContent += prop + '\t' + hasOwn + '\t' + event[prop] +'\n';
    }

    document.body.appendChild(pre);
});


Actual results:

I've attached a sample output.
(Reporter)

Updated

4 years ago
Component: Untriaged → DOM: Events
Product: Firefox → Core
That is correct; these properties are on the prototype, see <http://heycam.github.io/webidl/>.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → INVALID

Comment 2

4 years ago
And .isTrusted is [Unforgeable]
http://dom.spec.whatwg.org/#interface-event

So things seem to behave as expected.
(Reporter)

Comment 3

4 years ago
I see. Thanks for the explanations and references.
You need to log in before you can comment on or make changes to this bug.