test_matches.xhtml (1814B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 4 type="text/css"?> 5 <!-- 6 https://bugzilla.mozilla.org/show_bug.cgi?id=533596 7 --> 8 <window title="Mozilla Bug 533596" 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 11 12 <!-- test results are displayed in the html:body --> 13 <body xmlns="http://www.w3.org/1999/xhtml"> 14 15 <iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_matches.html" 16 onload="runTest(this)"> 17 </iframe> 18 </body> 19 20 <!-- test code goes here --> 21 <script type="application/javascript"><![CDATA[ 22 SimpleTest.waitForExplicitFinish(); 23 function runTest(ifr) 24 { 25 var doc = ifr.contentDocument; 26 var docElem = doc.documentElement; 27 28 var res = doc.createElement('div').matches('div'); 29 is(res, true, "matches call through xray, regular case"); 30 31 res = docElem.matches.call( 32 doc.createElement('div'), 'div'); 33 is(res, true, "matches call through xray, with .call"); 34 35 var sb = new Cu.Sandbox(ifr.contentWindow); 36 sb.doc = doc; 37 var str = "doc.documentElement.matches.call(doc.createElement( 'div' ),'div')"; 38 res = Cu.evalInSandbox(str, sb); 39 is(res, true, "matches call through xray (same origin), with .call"); 40 41 docElem.matches = function(){return false}; 42 res = docElem.matches.call(doc.createElement( 'div' ),'div'); 43 is(res, false, "shadowing matches with an expando on the xray wrapper"); 44 45 SimpleTest.finish(); 46 } 47 48 ]]></script> 49 </window>