test_bug658909.xul 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
  3. <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
  4. <!--
  5. https://bugzilla.mozilla.org/show_bug.cgi?id=658909
  6. -->
  7. <window title="Mozilla Bug 658909"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  10. <!-- test results are displayed in the html:body -->
  11. <body xmlns="http://www.w3.org/1999/xhtml">
  12. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=658909"
  13. target="_blank">Mozilla Bug 658909</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for call/apply-ing Xray methods.**/
  19. SimpleTest.waitForExplicitFinish();
  20. gLoadCount = 0;
  21. function frameLoaded() {
  22. if (++gLoadCount == frames.length)
  23. go();
  24. }
  25. function msg(a, b, testName) {
  26. return "(" + a.name + ", " + b.name + "): " + testName;
  27. }
  28. var testFunctions = {
  29. testDocumentElement: function(a, b, name) {
  30. var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
  31. is(getter.call(b.document), b.document.documentElement, msg(a, b, name));
  32. },
  33. testInvalidCall: function(a, b, name) {
  34. var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
  35. var threw = false;
  36. try { getter.call(b.document.body); } catch (e) { threw = true; };
  37. ok(threw, msg(a, b, name));
  38. },
  39. testStatus: function(a, b, name) {
  40. var setter = Object.prototype.__lookupSetter__.call(a, 'status');
  41. is(b.status, "", "Empty status");
  42. setter.call(b, "foopy");
  43. is(b.status, "foopy", msg(a, b, name));
  44. b.status = "";
  45. },
  46. testCreateElement: function(a, b, name) {
  47. is(a.document.createElement.call(b.document, 'div').ownerDocument, b.document, msg(a, b, name));
  48. },
  49. testWindowName: function(a, b, name) {
  50. var getter = Object.prototype.__lookupGetter__.call(a, 'name');
  51. is(getter.call(b), b.name, msg(a, b, name));
  52. },
  53. testCanvas: function(a, b, name) {
  54. var canvasA = a.document.createElement('canvas');
  55. var canvasB = b.document.createElement('canvas');
  56. var contextA = canvasA.getContext('2d');
  57. var contextB = canvasB.getContext('2d');
  58. var getter = Object.prototype.__lookupGetter__.call(contextA, 'canvas');
  59. is(getter.call(contextB), canvasB, msg(a, b, name));
  60. }
  61. };
  62. function go() {
  63. for (var i = 0; i < frames.length; ++i)
  64. frames[i].name = 'frame' + i;
  65. for (var i = 0; i < frames.length; ++i) {
  66. for (var j = 0; j < frames.length; ++j) {
  67. for (var k in testFunctions)
  68. testFunctions[k](frames[i], frames[j], k);
  69. }
  70. }
  71. SimpleTest.finish();
  72. }
  73. ]]>
  74. </script>
  75. <iframe id="frame1" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  76. <iframe id="frame2" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  77. <iframe id="frame3" onload="frameLoaded();" type="content" src="http://example.com/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  78. </window>