dom/tests/mochitest/dom-level2-core/test_namednodemapsetnameditemns03.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
     2 <html>
     3 <head>
     4 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
     5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     6 <title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns03</title>
     7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
     8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9 <script type="text/javascript" src="DOMTestCase.js"></script>
    10 <script type="text/javascript" src="exclusions.js"></script>
    11 <script type="text/javascript">
    12 // expose test function names
    13 function exposeTestFunctionNames()
    14 {
    15 return ['namednodemapsetnameditemns03'];
    16 }
    18 var docsLoaded = -1000000;
    19 var builder = null;
    21 //
    22 //   This function is called by the testing framework before
    23 //      running the test suite.
    24 //
    25 //   If there are no configuration exceptions, asynchronous
    26 //        document loading is started.  Otherwise, the status
    27 //        is set to complete and the exception is immediately
    28 //        raised when entering the body of the test.
    29 //
    30 function setUpPage() {
    31    setUpPageStatus = 'running';
    32    try {
    33      //
    34      //   creates test document builder, may throw exception
    35      //
    36      builder = createConfiguredBuilder();
    37        setImplementationAttribute("namespaceAware", true);
    39       docsLoaded = 0;
    41       var docRef = null;
    42       if (typeof(this.doc) != 'undefined') {
    43         docRef = this.doc;
    44       }
    45       docsLoaded += preload(docRef, "doc", "staffNS");
    47       var docAltRef = null;
    48       if (typeof(this.docAlt) != 'undefined') {
    49         docAltRef = this.docAlt;
    50       }
    51       docsLoaded += preload(docAltRef, "docAlt", "staffNS");
    53        if (docsLoaded == 2) {
    54           setUpPage = 'complete';
    55        }
    56     } catch(ex) {
    57     	catchInitializationError(builder, ex);
    58         setUpPage = 'complete';
    59     }
    60 }
    62 //
    63 //   This method is called on the completion of 
    64 //      each asychronous load started in setUpTests.
    65 //
    66 //   When every synchronous loaded document has completed,
    67 //      the page status is changed which allows the
    68 //      body of the test to be executed.
    69 function loadComplete() {
    70   if (++docsLoaded == 2) {
    71     setUpPageStatus = 'complete';
    72     runJSUnitTests();
    73     markTodos();
    74     SimpleTest.finish();
    75   }
    76 }
    78 var docName = 'namednodemapsetnameditemns03';
    81 /**
    82 * 
    83 	The method setNamedItemNS adds a node using its namespaceURI and localName and 
    84 	raises a WRONG_DOCUMENT_ERR if arg was created from a different document than the 
    85 	one that created this map.
    87 	Retreieve the second element whose local name is address and its attribute into a named node map.
    88 	Do the same for another document and retreive its street attribute.  Call the setNamedItemNS
    89 	using the first namedNodeMap and the retreive street attribute of the second.  This should
    90 	raise a WRONG_DOCUMENT_ERR. 
    92 * @author IBM
    93 * @author Neil Delima
    94 * @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS
    95 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=259
    96 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=408
    97 */
    98 function namednodemapsetnameditemns03() {
    99    var success;
   100     if(checkInitialization(builder, "namednodemapsetnameditemns03") != null) return;
   101     var doc;
   102       var docAlt;
   103       var attributes;
   104       var attributesAlt;
   105       var elementList;
   106       var elementListAlt;
   107       var element;
   108       var elementAlt;
   109       var attr;
   110       var newNode;
   111       var nullNS = null;
   114       var docRef = null;
   115       if (typeof(this.doc) != 'undefined') {
   116         docRef = this.doc;
   117       }
   118       doc = load(docRef, "doc", "staffNS");
   119       elementList = doc.getElementsByTagNameNS("*","address");
   120       element = elementList.item(1);
   121       attributes = element.attributes;
   124       var docAltRef = null;
   125       if (typeof(this.docAlt) != 'undefined') {
   126         docAltRef = this.docAlt;
   127       }
   128       docAlt = load(docAltRef, "docAlt", "staffNS");
   129       elementListAlt = docAlt.getElementsByTagNameNS("*","address");
   130       elementAlt = elementListAlt.item(1);
   131       attributesAlt = elementAlt.attributes;
   133       attr = attributesAlt.getNamedItemNS(nullNS,"street");
   134       newNode = attributesAlt.removeNamedItemNS(nullNS,"street");
   136 	{
   137 		success = false;
   138 		try {
   139             newNode = attributes.setNamedItemNS(attr);
   140         }
   141 		catch(ex) {
   142       success = (typeof(ex.code) != 'undefined' && ex.code == 4);
   143 		}
   144 		assertTrue("throw_WRONG_DOCUMENT_ERR",success);
   145 	}
   147 }
   149 </script>
   150 </head>
   151 <body>
   152 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns03</h2>
   153 <p></p>
   154 <p>
   155 Copyright (c) 2001-2004 World Wide Web Consortium, 
   156 (Massachusetts Institute of Technology, European Research Consortium 
   157 for Informatics and Mathematics, Keio University). All 
   158 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 
   159 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
   160 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   161 </p>
   162 </body>
   163 </html>

mercurial