Backed out 2 changesets (bug 957431) because we decided we're keeping Attr.ownerElement in the end

Backed out changeset ab12a8416a1d (bug 957431)
Backed out changeset 188d1e255d40 (bug 957431)
This commit is contained in:
Ehsan Akhgari 2014-03-21 16:04:09 -04:00
Родитель 7426fe9ae6
Коммит da255bec64
19 изменённых файлов: 961 добавлений и 14 удалений

Просмотреть файл

@ -16,6 +16,7 @@ DEPRECATED_OPERATION(RemoveAttributeNode)
DEPRECATED_OPERATION(CreateAttribute)
DEPRECATED_OPERATION(CreateAttributeNS)
DEPRECATED_OPERATION(Specified)
DEPRECATED_OPERATION(OwnerElement)
DEPRECATED_OPERATION(NodeValue)
DEPRECATED_OPERATION(TextContent)
DEPRECATED_OPERATION(EnablePrivilege)

Просмотреть файл

@ -135,13 +135,6 @@ Attr::GetContent() const
return GetContentInternal();
}
Element*
Attr::GetElement() const
{
nsIContent* content = GetContent();
return content ? content->AsElement() : nullptr;
}
nsresult
Attr::SetOwnerDocument(nsIDocument* aDocument)
{
@ -241,6 +234,29 @@ Attr::GetSpecified(bool* aSpecified)
return NS_OK;
}
Element*
Attr::GetOwnerElement(ErrorResult& aRv)
{
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
return GetContentInternal();
}
NS_IMETHODIMP
Attr::GetOwnerElement(nsIDOMElement** aOwnerElement)
{
NS_ENSURE_ARG_POINTER(aOwnerElement);
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
nsIContent* content = GetContentInternal();
if (content) {
return CallQueryInterface(content, aOwnerElement);
}
*aOwnerElement = nullptr;
return NS_OK;
}
void
Attr::GetNodeValueInternal(nsAString& aNodeValue)
{

Просмотреть файл

@ -57,7 +57,6 @@ public:
// nsIAttribute interface
void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
nsIContent *GetContent() const MOZ_OVERRIDE;
Element *GetElement() const;
nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
// nsINode interface
@ -95,6 +94,8 @@ public:
// XPCOM GetPrefix() is OK
// XPCOM GetLocalName() is OK
Element* GetOwnerElement(ErrorResult& aRv);
protected:
virtual Element* GetNameSpaceElement()
{

Просмотреть файл

@ -7265,7 +7265,10 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
// Remove from ownerElement.
nsRefPtr<Attr> adoptedAttr = static_cast<Attr*>(adoptedNode);
nsCOMPtr<Element> ownerElement = adoptedAttr->GetElement();
nsCOMPtr<Element> ownerElement = adoptedAttr->GetOwnerElement(rv);
if (rv.Failed()) {
return nullptr;
}
if (ownerElement) {
nsRefPtr<Attr> newAttr =

Просмотреть файл

@ -29,6 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=364413
var attrNode = test1.getAttributeNodeNS("http://www.foobar.com", "foo");
function mutationHandler(aEvent) {
ok(attrNode == aEvent.relatedNode);
ok(aEvent.target == attrNode.ownerElement);
}
function runTest() {

Просмотреть файл

@ -14,7 +14,7 @@
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[scriptable, builtinclass, uuid(58f9b5f5-0e39-4999-85b1-095895569c0e)]
[scriptable, builtinclass, uuid(a974a4d3-2ff1-445b-8b8e-0aada5d4eedc)]
interface nsIDOMAttr : nsIDOMNode
{
readonly attribute DOMString name;
@ -22,5 +22,8 @@ interface nsIDOMAttr : nsIDOMNode
attribute DOMString value;
// raises(DOMException) on setting
// Introduced in DOM Level 2:
readonly attribute nsIDOMElement ownerElement;
readonly attribute boolean isId;
};

Просмотреть файл

@ -50,6 +50,7 @@ RemoveAttributeNodeWarning=Use of removeAttributeNode() is deprecated. Use remov
CreateAttributeWarning=Use of document.createAttribute() is deprecated. Use element.setAttribute() instead.
CreateAttributeNSWarning=Use of document.createAttributeNS() is deprecated. Use element.setAttributeNS() instead.
SpecifiedWarning=Use of attributes' specified attribute is deprecated. It always returns true.
OwnerElementWarning=Use of attributes' ownerElement attribute is deprecated.
NodeValueWarning=Use of attributes' nodeValue attribute is deprecated. Use value instead.
TextContentWarning=Use of attributes' textContent attribute is deprecated. Use value instead.
EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code that runs with the system principal (e.g. an extension) instead.

Просмотреть файл

@ -28,6 +28,11 @@ support-files =
files/xhtml1-strict.dtd
files/xhtml1-transitional.dtd
[test_attrgetownerelement01.html]
[test_attrgetownerelement02.html]
[test_attrgetownerelement03.html]
[test_attrgetownerelement04.html]
[test_attrgetownerelement05.html]
[test_createAttributeNS01.html]
[test_createAttributeNS02.html]
[test_createAttributeNS03.html]
@ -234,6 +239,8 @@ support-files =
[test_nodenormalize01.html]
[test_normalize01.html]
[test_ownerDocument01.html]
[test_ownerElement01.html]
[test_ownerElement02.html]
[test_prefix01.html]
[test_prefix02.html]
[test_prefix03.html]

Просмотреть файл

@ -0,0 +1,134 @@
<!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/attrgetownerelement01</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 ['attrgetownerelement01'];
}
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();
setImplementationAttribute("namespaceAware", true);
setImplementationAttribute("validating", true);
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 = 'attrgetownerelement01';
/**
*
The "getOwnerElement()" will return the Element node this attribute is attached to or
null if this attribute is not in use.
Retreive the default attribute defaultAttr and check its owner element. Verify if the name
the nodeName of the returned ownerElement is emp:employee.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259
*/
function attrgetownerelement01() {
var success;
if(checkInitialization(builder, "attrgetownerelement01") != null) return;
var doc;
var attr;
var element;
var ownerElement;
var ownerElementName;
var elementList;
var attributes;
var nullNS = null;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
elementList = doc.getElementsByTagNameNS("http://www.nist.gov","employee");
element = elementList.item(1);
attributes = element.attributes;
attr = attributes.getNamedItemNS(nullNS,"defaultAttr");
ownerElement = attr.ownerElement;
ownerElementName = ownerElement.nodeName;
assertEquals("attrgetownerelement01","emp:employee",ownerElementName);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement01</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>

Просмотреть файл

@ -0,0 +1,127 @@
<!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/attrgetownerelement02</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 ['attrgetownerelement02'];
}
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();
setImplementationAttribute("namespaceAware", true);
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 = 'attrgetownerelement02';
/**
*
The "getOwnerElement()" will return the Element node this attribute
is attached to or null if this attribute is not in use.
Create a new element and attribute node, attach the attribute to the element.
Check the value of owner element of the new attribute node
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
*/
function attrgetownerelement02() {
var success;
if(checkInitialization(builder, "attrgetownerelement02") != null) return;
var doc;
var element;
var ownerElement;
var ownerElementName;
var attr;
var newAttr;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
element = doc.createElement("root");
attr = doc.createAttributeNS("http://www.w3.org/DOM/L1","L1:att");
newAttr = element.setAttributeNodeNS(attr);
ownerElement = attr.ownerElement;
ownerElementName = ownerElement.nodeName;
assertEquals("attrgetownerelement02","root".toLowerCase(),ownerElementName.toLowerCase());
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement02</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>

Просмотреть файл

@ -0,0 +1,119 @@
<!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/attrgetownerelement03</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 ['attrgetownerelement03'];
}
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 = 'attrgetownerelement03';
/**
*
The "getOwnerElement()" will return the Element node this attribute
is attached to or null if this attribute is not in use.
Create a new attribute node for this document node. Since the newly attribute is
not it use its owner element should be null.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
*/
function attrgetownerelement03() {
var success;
if(checkInitialization(builder, "attrgetownerelement03") != null) return;
var doc;
var ownerElement;
var attr;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
attr = doc.createAttributeNS("http://www.w3.org/DOM","dom:attr");
ownerElement = attr.ownerElement;
assertNull("attrgetownerelement03",ownerElement);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement03</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>

Просмотреть файл

@ -0,0 +1,140 @@
<!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/attrgetownerelement04</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 ['attrgetownerelement04'];
}
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();
setImplementationAttribute("namespaceAware", true);
docsLoaded = 0;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
docsLoaded += preload(docRef, "doc", "staffNS");
var docImpRef = null;
if (typeof(this.docImp) != 'undefined') {
docImpRef = this.docImp;
}
docsLoaded += preload(docImpRef, "docImp", "staff");
if (docsLoaded == 2) {
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 == 2) {
setUpPageStatus = 'complete';
runJSUnitTests();
markTodos();
SimpleTest.finish();
}
}
var docName = 'attrgetownerelement04';
/**
*
The "getOwnerElement()" will return the Element node this attribute is attached to or
null if this attribute is not in use.
Import an attribute node to another document. If an Attr node is imported, its
ownerElement attribute should be set to null. Verify if the ownerElement has been set
to null.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
*/
function attrgetownerelement04() {
var success;
if(checkInitialization(builder, "attrgetownerelement04") != null) return;
var doc;
var docImp;
var ownerElement;
var element;
var attr;
var attrImp;
var addresses;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
var docImpRef = null;
if (typeof(this.docImp) != 'undefined') {
docImpRef = this.docImp;
}
docImp = load(docImpRef, "docImp", "staff");
addresses = doc.getElementsByTagNameNS("http://www.nist.gov","address");
element = addresses.item(1);
assertNotNull("empAddressNotNull",element);
attr = element.getAttributeNodeNS("http://www.nist.gov","zone");
attrImp = docImp.importNode(attr,true);
ownerElement = attrImp.ownerElement;
assertNull("attrgetownerelement04",ownerElement);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement04</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>

Просмотреть файл

@ -0,0 +1,138 @@
<!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/attrgetownerelement05</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 ['attrgetownerelement05'];
}
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();
setImplementationAttribute("namespaceAware", true);
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 = 'attrgetownerelement05';
/**
*
The "getOwnerElement()" will return the Element node this attribute is attached to
or null if this attribute is not in use.
Retreive an element and its attributes. Then remove the element and check the name of
the ownerElement of attribute of the attribute "street".
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259
*/
function attrgetownerelement05() {
var success;
if(checkInitialization(builder, "attrgetownerelement05") != null) return;
var doc;
var element;
var ownerElement;
var parentElement;
var elementList;
var ownerElementName;
var attr;
var removedChild;
var nodeMap;
var nullNS = null;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
elementList = doc.getElementsByTagNameNS("*","address");
element = elementList.item(1);
parentElement = element.parentNode;
nodeMap = element.attributes;
removedChild = parentElement.removeChild(element);
attr = nodeMap.getNamedItemNS(nullNS,"street");
ownerElement = attr.ownerElement;
ownerElementName = ownerElement.nodeName;
assertEquals("attrgetownerelement05","address",ownerElementName);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/attrgetownerelement05</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>

Просмотреть файл

@ -144,6 +144,9 @@ function importNode01() {
assertNotNull("aNode",aNode);
assertURIEquals("systemId",null,null,null,"staffNS.dtd",null,null,null,null,system);
attrOwnerElement = aNode.ownerElement;
assertNull("ownerElement",attrOwnerElement);
specified = aNode.specified;
assertTrue("specified",specified);

Просмотреть файл

@ -0,0 +1,129 @@
<!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/ownerElement01</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 ['ownerElement01'];
}
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", "staff");
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 = 'ownerElement01';
/**
*
The "getOwnerElement()" will return the Element node this attribute
is attached to or null if this attribute is not in use.
Get the "domestic" attribute from the first "address" node.
Apply the "getOwnerElement()" method to get the Element associated
with the attribute. The value returned should be "address".
* @author NIST
* @author Mary Brady
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095
*/
function ownerElement01() {
var success;
if(checkInitialization(builder, "ownerElement01") != null) return;
var doc;
var addressList;
var testNode;
var attributes;
var domesticAttr;
var elementNode;
var name;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staff");
addressList = doc.getElementsByTagName("address");
testNode = addressList.item(0);
attributes = testNode.attributes;
domesticAttr = attributes.getNamedItem("domestic");
elementNode = domesticAttr.ownerElement;
name = elementNode.nodeName;
assertEquals("throw_Equals","address",name);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement01</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>

Просмотреть файл

@ -0,0 +1,120 @@
<!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/ownerElement02</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 ['ownerElement02'];
}
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", "staff");
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 = 'ownerElement02';
/**
*
The "getOwnerElement()" will return the Element node this attribute
is attached to or null if this attribute is not in use.
Create a new attribute.
Apply the "getOwnerElement()" method to get the Element associated
with the attribute. The value returned should be "null" since this
attribute is not in use.
* @author NIST
* @author Mary Brady
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement
*/
function ownerElement02() {
var success;
if(checkInitialization(builder, "ownerElement02") != null) return;
var doc;
var newAttr;
var elementNode;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staff");
newAttr = doc.createAttribute("newAttribute");
elementNode = newAttr.ownerElement;
assertNull("throw_Null",elementNode);
}
</script>
</head>
<body>
<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/ownerElement02</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>

Просмотреть файл

@ -24,4 +24,8 @@ interface Attr : Node {
partial interface Attr {
readonly attribute boolean specified;
[GetterThrows]
readonly attribute Element? ownerElement;
};

Просмотреть файл

@ -58,10 +58,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=319374
// Test 2: If the context node is in anonymous content, changing some
// other anonymous tree shouldn't cause XPath result to throw.
var anonElem1 =
var anonAttr1 =
getAnonymousNodes(document.getElementById('content').
firstChild)[0];
var anonAttr1 = anonElem1.getAttributeNode('attr');
firstChild)[0].getAttributeNode('attr');
var anonAttr2 =
getAnonymousNodes(document.getElementById('content').
lastChild)[0].getAttributeNode('attr');
@ -92,7 +91,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=319374
UNORDERED_NODE_ITERATOR_TYPE,
null);
// Attribute changing in the same anonymous tree.
anonElem1.setAttribute("foo", "bar");
anonAttr1.ownerElement.setAttribute("foo", "bar");
resultAttr = xp3.iterateNext();
ok(resultAttr == anonAttr1,
"XPathEvaluator should have thrown an exception!")

Просмотреть файл

@ -50,6 +50,7 @@ RemoveAttributeNodeWarning=Use of removeAttributeNode() is deprecated. Use remov
CreateAttributeWarning=Use of document.createAttribute() is deprecated. Use element.setAttribute() instead.
CreateAttributeNSWarning=Use of document.createAttributeNS() is deprecated. Use element.setAttributeNS() instead.
SpecifiedWarning=Use of attributes' specified attribute is deprecated. It always returns true.
OwnerElementWarning=Use of attributes' ownerElement attribute is deprecated.
NodeValueWarning=Use of attributes' nodeValue attribute is deprecated. Use value instead.
TextContentWarning=Use of attributes' textContent attribute is deprecated. Use value instead.
EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code that runs with the system principal (e.g. an extension) instead.