Home | History | Annotate | Download | only in script-tests
      1 description("Test to make sure EntityReference nodes are always treated readonly")
      2 
      3 var xmlDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
      4 var xmlDoc2 = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
      5 var entityReference = xmlDoc.createEntityReference("gt");
      6 
      7 shouldThrow("xmlDoc2.adoptNode(entityReference)");
      8 shouldBe("entityReference.ownerDocument", "xmlDoc")
      9 
     10 // nodeValue is defined to be null for Entity Reference nodes, and thus should silently fail to modify
     11 // Spec is ambigious as to if we should throw here or not.  I've requested clarification:
     12 // http://lists.w3.org/Archives/Public/www-dom/2008JanMar/0009.html
     13 shouldThrow("entityReference.nodeValue = 'foo'");
     14 shouldBe("entityReference.nodeValue", "null");
     15 
     16 shouldThrow("entityReference.prefix = 'foo'");
     17 shouldBe("entityReference.prefix", "null");
     18 
     19 shouldThrow("entityReference.textContent = 'foo'");
     20 shouldBe("entityReference.textContent", "'>'");
     21 
     22 var childrenBeforeFailedAppend = entityReference.childNodes.length;
     23 shouldBe("childrenBeforeFailedAppend", "1");
     24 var text = document.createTextNode("FAIL");
     25 shouldThrow("entityReference.appendChild(text)");
     26 shouldBe("entityReference.childNodes.length", "childrenBeforeFailedAppend");
     27 
     28 childrenBeforeFailedAppend = entityReference.childNodes.length;
     29 shouldBe("childrenBeforeFailedAppend", "1");
     30 shouldThrow("entityReference.insertBefore(text, entityReference.firstChild)");
     31 shouldBe("entityReference.childNodes.length", "childrenBeforeFailedAppend");
     32 
     33 var successfullyParsed = true;
     34