test_bug795275.xul 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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=795275
  6. -->
  7. <window title="Mozilla Bug 795275"
  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=795275"
  13. target="_blank">Mozilla Bug 795275</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for Warning in content scopes about Components. **/
  19. SimpleTest.waitForExplicitFinish();
  20. SimpleTest.executeSoon(startLoad);
  21. function startLoad() {
  22. for (var i = 1; i <= document.getElementsByTagName('iframe').length; ++i) {
  23. var frame = document.getElementById('frame' + i);
  24. frame.contentWindow.location = 'http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug795275.html';
  25. frame.onload = frameLoaded;
  26. }
  27. }
  28. // Set up our console listener.
  29. var gWarnings = 0;
  30. function onWarning(consoleMessage) {
  31. if (/soon be removed/.test(consoleMessage.message))
  32. gWarnings++;
  33. }
  34. var gListener = {
  35. observe: onWarning,
  36. QueryInterface: function (iid) {
  37. if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
  38. !iid.equals(Components.interfaces.nsISupports)) {
  39. throw Components.results.NS_ERROR_NO_INTERFACE;
  40. }
  41. return this;
  42. }
  43. };
  44. var gConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
  45. .getService(Components.interfaces.nsIConsoleService);
  46. gConsoleService.registerListener(gListener);
  47. // Wait for all four child frame to load.
  48. var gLoadCount = 0;
  49. function frameLoaded() {
  50. if (++gLoadCount == document.getElementsByTagName('iframe').length)
  51. go();
  52. }
  53. function getWin(id) { return document.getElementById(id).contentWindow.wrappedJSObject; }
  54. function go() {
  55. getWin('frame1').touchComponents();
  56. getWin('frame2').touchInterfaces();
  57. getWin('frame4').touchComponents();
  58. getWin('frame4').touchInterfaces();
  59. // This shouldn't warn.
  60. getWin('frame5').touchViaXBL();
  61. // Warnings are dispatched async, so stick ourselves at the end of the event
  62. // queue.
  63. setTimeout(done, 0);
  64. }
  65. function done() {
  66. gConsoleService.unregisterListener(gListener);
  67. is(gWarnings, 3, "Got the right number of warnings");
  68. SimpleTest.finish();
  69. }
  70. ]]>
  71. </script>
  72. <iframe id="frame1"/>
  73. <iframe id="frame2"/>
  74. <iframe id="frame3"/>
  75. <iframe id="frame4"/>
  76. <iframe id="frame5"/>
  77. </window>