Bug 1055776 - Move namespaceURI, prefix, localName from Node to Element; r=bz
authorAryeh Gregor <ayg@aryeh.name>
Wed, 13 Apr 2016 15:21:12 +0300
changeset 330886 5dde3034452c0b87040178204bb280d139e3c6ff
parent 330885 ff56abc1768b5d50177b69e8edb43dd6cf5ac998
child 330887 349594185facf0e5e093be7c71b3be8e621db55d
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1055776
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1055776 - Move namespaceURI, prefix, localName from Node to Element; r=bz
dom/base/test/test_bug352728.html
dom/base/test/test_bug352728.xhtml
dom/imptests/failures/html/dom/test_interfaces.html.json
dom/tests/mochitest/dom-level2-core/mochitest.ini
dom/tests/mochitest/dom-level2-core/test_localName03.html
dom/tests/mochitest/dom-level2-core/test_prefix02.html
dom/webidl/Attr.webidl
dom/webidl/Element.webidl
dom/webidl/Node.webidl
testing/web-platform/meta/dom/historical.html.ini
testing/web-platform/meta/dom/interfaces.html.ini
--- a/dom/base/test/test_bug352728.html
+++ b/dom/base/test/test_bug352728.html
@@ -35,18 +35,18 @@ function checkInterfaces(aNode, aNodeTyp
   }
 }
 
 function testCharacterData(aNode, aText)
 {
   is(aNode.length, aText.length, "Text length should match");
   is(aNode.data, aText, "Text content should match");
   is(aNode.nodeValue, aText, "Check nodeValue");
-  is(aNode.localName, null, "Check localName")
-  is(aNode.namespaceURI, null, "Check namespaceURI");
+  is(aNode.localName, undefined, "Check localName")
+  is(aNode.namespaceURI, undefined, "Check namespaceURI");
 }
 
 function testComment(aText)
 {
   try {
     var comment = document.createComment(aText);
     var types = [ Comment, CharacterData, Node ];
     checkTypes(comment, "comment", types);
@@ -85,18 +85,18 @@ function testPI(aTarget, aData, aShouldS
     var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
                        "nsIDOMEventTarget" ];
     checkInterfaces(pi, "processing instruction", interfaces);
 
     is(pi.target, aTarget, "Check target");
     is(pi.data, aData, "Check data");
     is(pi.nodeName, aTarget, "Check nodeName");
     is(pi.nodeValue, aData, "Check nodeValue");
-    is(pi.localName, null, "Check localName")
-    is(pi.namespaceURI, null, "Check namespaceURI");
+    is(pi.localName, undefined, "Check localName")
+    is(pi.namespaceURI, undefined, "Check namespaceURI");
     
     is(pi.nodeType, Node.PROCESSING_INSTRUCTION_NODE, "Check nodeType");
 
     if (!aShouldSucceed) {
       ok(false, "Invalid processing instruction creation", aReason);
     }
   } catch (e) {
     if (aShouldSucceed) {
--- a/dom/base/test/test_bug352728.xhtml
+++ b/dom/base/test/test_bug352728.xhtml
@@ -59,18 +59,18 @@ function checkInterfaces(aNode, aNodeTyp
   }
 }
 
 function testCharacterData(aNode, aText)
 {
   is(aNode.length, aText.length, "Text length should match");
   is(aNode.data, aText, "Text content should match");
   is(aNode.nodeValue, aText, "Check nodeValue");
-  is(aNode.localName, null, "Check localName")
-  is(aNode.namespaceURI, null, "Check namespaceURI");
+  is(aNode.localName, undefined, "Check localName")
+  is(aNode.namespaceURI, undefined, "Check namespaceURI");
 }
 
 function testComment(aText)
 {
   try {
     var comment = document.createComment(aText);
     var types = [ Comment, CharacterData, Node ];
     checkTypes(comment, "comment", types);
@@ -129,18 +129,18 @@ function testPI(aTarget, aData, aShouldS
     var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
                        "nsIDOMEventTarget" ];
     checkInterfaces(pi, "processing instruction", interfaces);
 
     is(pi.target, aTarget, "Check target");
     is(pi.data, aData, "Check data");
     is(pi.nodeName, aTarget, "Check nodeName");
     is(pi.nodeValue, aData, "Check nodeValue");
-    is(pi.localName, null, "Check localName")
-    is(pi.namespaceURI, null, "Check namespaceURI");
+    is(pi.localName, undefined, "Check localName")
+    is(pi.namespaceURI, undefined, "Check namespaceURI");
     
     is(pi.nodeType, Node.PROCESSING_INSTRUCTION_NODE, "Check nodeType");
 
     if (!aShouldSucceed) {
       ok(0, "Invalid processing instruction creation", aReason);
     }
   } catch (e) {
     if (aShouldSucceed) {
--- a/dom/imptests/failures/html/dom/test_interfaces.html.json
+++ b/dom/imptests/failures/html/dom/test_interfaces.html.json
@@ -20,19 +20,16 @@
   "DocumentType interface: operation after([object Object],[object Object])": true,
   "DocumentType interface: operation replace([object Object],[object Object])": true,
   "DocumentType interface: document.doctype must inherit property \"before\" with the proper type (3)": true,
   "DocumentType interface: calling before([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
   "DocumentType interface: document.doctype must inherit property \"after\" with the proper type (4)": true,
   "DocumentType interface: calling after([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
   "DocumentType interface: document.doctype must inherit property \"replace\" with the proper type (5)": true,
   "DocumentType interface: calling replace([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
-  "Element interface: attribute namespaceURI": true,
-  "Element interface: attribute prefix": true,
-  "Element interface: attribute localName": true,
   "Element interface: operation prepend([object Object],[object Object])": true,
   "Element interface: operation append([object Object],[object Object])": true,
   "Element interface: operation before([object Object],[object Object])": true,
   "Element interface: operation after([object Object],[object Object])": true,
   "Element interface: operation replace([object Object],[object Object])": true,
   "Element interface: element must inherit property \"prepend\" with the proper type (23)": true,
   "Element interface: calling prepend([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
   "Element interface: element must inherit property \"append\" with the proper type (24)": true,
--- a/dom/tests/mochitest/dom-level2-core/mochitest.ini
+++ b/dom/tests/mochitest/dom-level2-core/mochitest.ini
@@ -187,17 +187,16 @@ support-files =
 [test_importNode12.html]
 [test_importNode13.html]
 [test_importNode14.html]
 [test_importNode15.html]
 [test_importNode16.html]
 [test_importNode17.html]
 [test_localName01.html]
 [test_localName02.html]
-[test_localName03.html]
 [test_localName04.html]
 [test_namednodemapgetnameditemns01.html]
 [test_namednodemapgetnameditemns02.html]
 [test_namednodemapgetnameditemns03.html]
 [test_namednodemapgetnameditemns04.html]
 [test_namednodemapgetnameditemns05.html]
 [test_namednodemapgetnameditemns06.html]
 [test_namednodemapremovenameditemns01.html]
@@ -234,17 +233,16 @@ support-files =
 [test_nodehasattributes03.html]
 [test_nodehasattributes04.html]
 [test_nodenormalize01.html]
 [test_normalize01.html]
 [test_ownerDocument01.html]
 [test_ownerElement01.html]
 [test_ownerElement02.html]
 [test_prefix01.html]
-[test_prefix02.html]
 [test_prefix03.html]
 [test_prefix04.html]
 [test_publicId01.html]
 [test_removeAttributeNS01.html]
 [test_removeAttributeNS02.html]
 [test_removeNamedItemNS01.html]
 [test_removeNamedItemNS02.html]
 [test_removeNamedItemNS03.html]
deleted file mode 100644
--- a/dom/tests/mochitest/dom-level2-core/test_localName03.html
+++ /dev/null
@@ -1,127 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName03</title>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
-<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<script type="text/javascript" src="DOMTestCase.js"></script>
-<script type="text/javascript" src="exclusions.js"></script>
-<script type="text/javascript">
-// expose test function names
-function exposeTestFunctionNames()
-{
-return ['localName03'];
-}
-
-var docsLoaded = -1000000;
-var builder = null;
-
-//
-//   This function is called by the testing framework before
-//      running the test suite.
-//
-//   If there are no configuration exceptions, asynchronous
-//        document loading is started.  Otherwise, the status
-//        is set to complete and the exception is immediately
-//        raised when entering the body of the test.
-//
-function setUpPage() {
-   setUpPageStatus = 'running';
-   try {
-     //
-     //   creates test document builder, may throw exception
-     //
-     builder = createConfiguredBuilder();
-
-      docsLoaded = 0;
-      
-      var docRef = null;
-      if (typeof(this.doc) != 'undefined') {
-        docRef = this.doc;
-      }
-      docsLoaded += preload(docRef, "doc", "staffNS");
-        
-       if (docsLoaded == 1) {
-          setUpPage = 'complete';
-       }
-    } catch(ex) {
-    	catchInitializationError(builder, ex);
-        setUpPage = 'complete';
-    }
-}
-
-//
-//   This method is called on the completion of 
-//      each asychronous load started in setUpTests.
-//
-//   When every synchronous loaded document has completed,
-//      the page status is changed which allows the
-//      body of the test to be executed.
-function loadComplete() {
-  if (++docsLoaded == 1) {
-    setUpPageStatus = 'complete';
-    runJSUnitTests();
-    markTodos();
-    SimpleTest.finish();
-  }
-}
-
-var docName = 'localName03';
-
-
-/**
-* 
-    The "getLocalName()" method for a Node
-    returns the local part of the qualified name of this node,
-    and for nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE
-    and nodes created with a DOM Level 1 method, this is null.
-    
-    Retrieve the first employeeId node and get the first child of this node.
-    Since the first child is Text node invoking the "getLocalName()"   
-    method will cause "null" to be returned. 
-
-* @author NIST
-* @author Mary Brady
-* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN
-*/
-function localName03() {
-   var success;
-    if(checkInitialization(builder, "localName03") != null) return;
-    var doc;
-      var elementList;
-      var testEmployee;
-      var textNode;
-      var localName;
-      
-      var docRef = null;
-      if (typeof(this.doc) != 'undefined') {
-        docRef = this.doc;
-      }
-      doc = load(docRef, "doc", "staffNS");
-      elementList = doc.getElementsByTagName("employeeId");
-      testEmployee = elementList.item(0);
-      textNode = testEmployee.firstChild;
-
-      localName = textNode.localName;
-
-      assertNull("textNodeLocalName",localName);
-    
-}
-
-</script>
-</head>
-<body>
-<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/localName03</h2>
-<p></p>
-<p>
-Copyright (c) 2001-2004 World Wide Web Consortium, 
-(Massachusetts Institute of Technology, European Research Consortium 
-for Informatics and Mathematics, Keio University). All 
-Rights Reserved. This work is distributed under the <a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C(r) Software License</a> in the 
-hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
-</p>
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/dom-level2-core/test_prefix02.html
+++ /dev/null
@@ -1,128 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix02</title>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
-<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<script type="text/javascript" src="DOMTestCase.js"></script>
-<script type="text/javascript" src="exclusions.js"></script>
-<script type="text/javascript">
-// expose test function names
-function exposeTestFunctionNames()
-{
-return ['prefix02'];
-}
-
-var docsLoaded = -1000000;
-var builder = null;
-
-//
-//   This function is called by the testing framework before
-//      running the test suite.
-//
-//   If there are no configuration exceptions, asynchronous
-//        document loading is started.  Otherwise, the status
-//        is set to complete and the exception is immediately
-//        raised when entering the body of the test.
-//
-function setUpPage() {
-   setUpPageStatus = 'running';
-   try {
-     //
-     //   creates test document builder, may throw exception
-     //
-     builder = createConfiguredBuilder();
-
-      docsLoaded = 0;
-      
-      var docRef = null;
-      if (typeof(this.doc) != 'undefined') {
-        docRef = this.doc;
-      }
-      docsLoaded += preload(docRef, "doc", "staffNS");
-        
-       if (docsLoaded == 1) {
-          setUpPage = 'complete';
-       }
-    } catch(ex) {
-    	catchInitializationError(builder, ex);
-        setUpPage = 'complete';
-    }
-}
-
-//
-//   This method is called on the completion of 
-//      each asychronous load started in setUpTests.
-//
-//   When every synchronous loaded document has completed,
-//      the page status is changed which allows the
-//      body of the test to be executed.
-function loadComplete() {
-  if (++docsLoaded == 1) {
-    setUpPageStatus = 'complete';
-    runJSUnitTests();
-    markTodos();
-    SimpleTest.finish();
-  }
-}
-
-var docName = 'prefix02';
-
-
-/**
-* 
-    The "getPrefix()" method
-    returns the namespace prefix of this node, or null if unspecified.
-    For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE,
-    this is always null.
-    
-    Retrieve the first emp:employeeId node and get the first child of this node.
-    Since the first child is Text node invoking the "getPrefix()"   
-    method will cause "null" to be returned. 
-
-* @author NIST
-* @author Mary Brady
-* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix
-*/
-function prefix02() {
-   var success;
-    if(checkInitialization(builder, "prefix02") != null) return;
-    var doc;
-      var elementList;
-      var testEmployee;
-      var textNode;
-      var prefix;
-      
-      var docRef = null;
-      if (typeof(this.doc) != 'undefined') {
-        docRef = this.doc;
-      }
-      doc = load(docRef, "doc", "staffNS");
-      elementList = doc.getElementsByTagName("emp:employeeId");
-      testEmployee = elementList.item(0);
-      assertNotNull("empEmployeeNotNull",testEmployee);
-textNode = testEmployee.firstChild;
-
-      prefix = textNode.prefix;
-
-      assertNull("textNodePrefix",prefix);
-    
-}
-
-</script>
-</head>
-<body>
-<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/prefix02</h2>
-<p></p>
-<p>
-Copyright (c) 2001-2004 World Wide Web Consortium, 
-(Massachusetts Institute of Technology, European Research Consortium 
-for Informatics and Mathematics, Keio University). All 
-Rights Reserved. This work is distributed under the <a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C(r) Software License</a> in the 
-hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
-</p>
-</body>
-</html>
--- a/dom/webidl/Attr.webidl
+++ b/dom/webidl/Attr.webidl
@@ -10,18 +10,21 @@
  * liability, trademark and document use rules apply.
  */
 
 interface Attr : Node {
   readonly attribute DOMString localName;
            [SetterThrows]
            attribute DOMString value;
 
+  [Constant]
   readonly attribute DOMString name;
+  [Constant]
   readonly attribute DOMString? namespaceURI;
+  [Constant]
   readonly attribute DOMString? prefix;
 
   readonly attribute boolean specified;
 };
 
 // Mozilla extensions
 
 partial interface Attr {
--- a/dom/webidl/Element.webidl
+++ b/dom/webidl/Element.webidl
@@ -9,24 +9,23 @@
  * http://dev.w3.org/csswg/cssom-view/ and
  * http://www.w3.org/TR/selectors-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 interface Element : Node {
-/*
-  We haven't moved these from Node to Element like the spec wants.
+  [Constant]
+  readonly attribute DOMString? namespaceURI;
+  [Constant]
+  readonly attribute DOMString? prefix;
+  [Constant]
+  readonly attribute DOMString localName;
 
-  [Throws]
-  readonly attribute DOMString? namespaceURI;
-  readonly attribute DOMString? prefix;
-  readonly attribute DOMString localName;
-*/
   // Not [Constant] because it depends on which document we're in
   [Pure]
   readonly attribute DOMString tagName;
 
   [Pure]
            attribute DOMString id;
   [Pure]
            attribute DOMString className;
--- a/dom/webidl/Node.webidl
+++ b/dom/webidl/Node.webidl
@@ -90,26 +90,16 @@ interface Node : EventTarget {
   [Pure]
   DOMString? lookupPrefix(DOMString? namespace);
   [Pure]
   DOMString? lookupNamespaceURI(DOMString? prefix);
   [Pure]
   boolean isDefaultNamespace(DOMString? namespace);
 
   // Mozilla-specific stuff
-  // These have been moved to Element in the spec.
-  // If we move namespaceURI, prefix and localName to Element they should return
-  // a non-nullable type.
-  [Constant]
-  readonly attribute DOMString? namespaceURI;
-  [Constant]
-  readonly attribute DOMString? prefix;
-  [Constant]
-  readonly attribute DOMString? localName;
-
   [Throws, Func="IsChromeOrXBL"]
   any setUserData(DOMString key, any data);
   [Throws, Func="IsChromeOrXBL"]
   any getUserData(DOMString key);
   [ChromeOnly]
   readonly attribute Principal nodePrincipal;
   [ChromeOnly]
   readonly attribute URI? baseURIObject;
--- a/testing/web-platform/meta/dom/historical.html.ini
+++ b/testing/web-platform/meta/dom/historical.html.ini
@@ -4,17 +4,8 @@
     expected: FAIL
 
   [Historical DOM features must be removed: DOMError]
     expected: FAIL
 
   [Historical DOM features must be removed: createCDATASection]
     expected: FAIL
 
-  [Node member must be nuked: namespaceURI]
-    expected: FAIL
-
-  [Node member must be nuked: prefix]
-    expected: FAIL
-
-  [Node member must be nuked: localName]
-    expected: FAIL
-
--- a/testing/web-platform/meta/dom/interfaces.html.ini
+++ b/testing/web-platform/meta/dom/interfaces.html.ini
@@ -106,25 +106,16 @@
     expected: FAIL
 
   [DocumentType interface: document.doctype must inherit property "replaceWith" with the proper type (5)]
     expected: FAIL
 
   [DocumentType interface: calling replaceWith([object Object\],[object Object\]) on document.doctype with too few arguments must throw TypeError]
     expected: FAIL
 
-  [Element interface: attribute namespaceURI]
-    expected: FAIL
-
-  [Element interface: attribute prefix]
-    expected: FAIL
-
-  [Element interface: attribute localName]
-    expected: FAIL
-
   [Element interface: operation prepend([object Object\],[object Object\])]
     expected: FAIL
 
   [Element interface: operation append([object Object\],[object Object\])]
     expected: FAIL
 
   [Element interface: operation query(DOMString)]
     expected: FAIL