test_matches.xul 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 type="application/javascript"
  11. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  12. <!-- test results are displayed in the html:body -->
  13. <body xmlns="http://www.w3.org/1999/xhtml">
  14. <iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_matches.html"
  15. onload="runTest(this)">
  16. </iframe>
  17. </body>
  18. <!-- test code goes here -->
  19. <script type="application/javascript"><![CDATA[
  20. SimpleTest.waitForExplicitFinish();
  21. function runTest(ifr)
  22. {
  23. var doc = ifr.contentDocument;
  24. var docElem = doc.documentElement;
  25. var res = doc.createElement('div').matches('div');
  26. is(res, true, "matches call through xray, regular case");
  27. res = docElem.matches.call(
  28. doc.createElement('div'), 'div');
  29. is(res, true, "matches call through xray, with .call");
  30. var sb = new Components.utils.Sandbox(ifr.contentWindow);
  31. sb.doc = doc;
  32. var str = "doc.documentElement.matches.call(doc.createElement( 'div' ),'div')";
  33. res = Components.utils.evalInSandbox(str, sb);
  34. is(res, true, "matches call through xray (same origin), with .call");
  35. docElem.matches = function(){return false};
  36. res = docElem.matches.call(doc.createElement( 'div' ),'div');
  37. is(res, false, "shadowing matches with an expando on the xray wrapper");
  38. SimpleTest.finish();
  39. }
  40. ]]></script>
  41. </window>