1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/chrome/test_bug683852.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=683852 1.9 +--> 1.10 +<window title="Mozilla Bug 683852" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + <button value="testbutton" id="testbutton"/> 1.14 + <!-- test results are displayed in the html:body --> 1.15 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=683852" 1.17 + target="_blank" id="link">Mozilla Bug 683852</a> 1.18 + </body> 1.19 + 1.20 + <!-- test code goes here --> 1.21 + <script type="application/javascript"> 1.22 + <![CDATA[ 1.23 + /** Test for Bug 683852 **/ 1.24 + SimpleTest.waitForExplicitFinish(); 1.25 + 1.26 + function startTest() { 1.27 + is(document.contains(document), true, "Document should contain itself!"); 1.28 + 1.29 + var tb = document.getElementById("testbutton"); 1.30 + is(document.contains(tb), true, "Document should contain element in it!"); 1.31 + is(tb.contains(tb), true, "Element should contain itself.") 1.32 + var anon = document.getAnonymousElementByAttribute(tb, "anonid", "button-box"); 1.33 + is(document.contains(anon), false, "Document should not contain anonymous element in it!"); 1.34 + is(tb.contains(anon), false, "Element should not contain anonymous element in it!"); 1.35 + is(anon.contains(anon), true, "Anonymous element should contain itself.") 1.36 + is(document.documentElement.contains(tb), true, "Element should contain element in it!"); 1.37 + is(document.contains(document.createElement("foo")), false, "Document shouldn't contain element which is't in the document"); 1.38 + is(document.contains(document.createTextNode("foo")), false, "Document shouldn't contain text node which is't in the document"); 1.39 + 1.40 + var link = document.getElementById("link"); 1.41 + is(document.contains(link.firstChild), true, 1.42 + "Document should contain a text node in it."); 1.43 + is(link.contains(link.firstChild), true, 1.44 + "Element should contain a text node in it."); 1.45 + is(link.firstChild.contains(link), false, "text node shouldn't contain its parent."); 1.46 + 1.47 + is(document.contains(null), false, "Document shouldn't contain null."); 1.48 + 1.49 + var pi = document.createProcessingInstruction("adf", "asd"); 1.50 + is(pi.contains(document), false, "Processing instruction shouldn't contain document"); 1.51 + document.documentElement.appendChild(pi); 1.52 + document.contains(pi, true, "Document should contain processing instruction"); 1.53 + 1.54 + var df = document.createRange().createContextualFragment("<div>foo</div>"); 1.55 + is(df.contains(df.firstChild), true, "Document fragment should contain its child"); 1.56 + is(df.contains(df.firstChild.firstChild), true, 1.57 + "Document fragment should contain its descendant"); 1.58 + is(df.contains(df), true, "Document fragment should contain itself."); 1.59 + 1.60 + var d = document.implementation.createHTMLDocument(""); 1.61 + is(document.contains(d), false, 1.62 + "Document shouldn't contain another document."); 1.63 + is(document.contains(d.createElement("div")), false, 1.64 + "Document shouldn't contain an element from another document."); 1.65 + 1.66 + SimpleTest.finish(); 1.67 + } 1.68 + 1.69 + addLoadEvent(startTest); 1.70 + ]]> 1.71 + </script> 1.72 +</window>