This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13752 - Figure out what 'delete window.Node' should do
Summary: Figure out what 'delete window.Node' should do
Status: CLOSED NEEDSINFO
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 18:45 UTC by Ms2ger
Modified: 2011-08-29 03:25 UTC (History)
3 users (show)

See Also:


Attachments

Description Ms2ger 2011-08-10 18:45:57 UTC
From <http://dev.w3.org/2006/webapi/WebIDL/#es-interfaces> and <http://es5.github.com/#x8.12.7>, I would assume 'delete window.Node' returns true and removes the property, but that doesn't seem to be the case in browsers. They seem to all return true and still keep the property around.
Comment 1 Cameron McCormack 2011-08-25 23:18:54 UTC
Testing with http://people.mozilla.org/~cmccormack/tests/interface-object-property.html, I find that Opera, Firefox and IE allow the property to be deleted, while Safari reports the property as non-configurable so refuses to delete it and Chrome reports the property as configurable but still refuses to delete it.

Do you have a test case showing interface object properties being deleted in Opera/Firefox/IE?
Comment 2 Ms2ger 2011-08-26 09:57:57 UTC
OK, looks like the spec is correct in the general case. However, something goes wrong with window.Node in particular in Gecko; I'm assuming that's a Gecko bug. (See <http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1120>.)

I'm satisfied with your response.
Comment 3 Ms2ger 2011-08-28 17:59:53 UTC
(And for people who are interested: <http://w3c-test.org/webapps/DOMCore/tests/submissions/Ms2ger/interfaces.html>.)
Comment 4 Garrett 2011-08-29 03:25:10 UTC
Here is your code:

function testInterfaceDeletable(iface) {
  test(function() {
    assert_true(!!window[iface], "Interface should exist.")
    assert_true(delete window[iface], "The delete operator should return true.")
    assert_equals(window[iface], undefined, "Interface should be gone.")
}
 Avoid getting bit by ASI bugs by consistently using explicit semicolons where they are required.

The delete operator does not "return" anything. The delete operator is just what it is: an operator. It performs an operation which has a boolean result. 

test(function() {
  for (var p in window) {
    interfaces.forEach(function(i) {
      assert_not_equals(p, i)
    })
  }
}, "Interface objects properties should not be Enumerable")

If `window` is specified to have own interface objects as own properties, then you can use:

({}).propertyIsEnumerable.call(window, "Node");

Otherwise, if interface objects can exist in `window` prototype chain, `propertyIsEnumerable`, which doesn't check the object's prototype, won't work there.

Does WebIDL or HTML5 specify `window` to have `Object.prototype` on its prototype chain? If so, then the code could use `window.propertyIsEnumerable("Node")`.