file_bug1271240.xul 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
  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=1271240
  7. -->
  8. <window title="Mozilla Bug 1271240"
  9. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="run();">
  10. <!-- test code goes here -->
  11. <script type="application/javascript">
  12. <![CDATA[
  13. function ok(cond, msg) {
  14. opener.wrappedJSObject.ok(cond, msg);
  15. }
  16. function is(actual, expected, msg) {
  17. opener.wrappedJSObject.is(actual, expected, msg);
  18. }
  19. /** Test for Bug 1271240 **/
  20. function run() {
  21. // test non-remote, non-prerendered browser
  22. createBrowser(false, false)
  23. .then(browser => verifyBrowser(browser, false, false))
  24. // test non-remote, prerendered browser
  25. .then(() => createBrowser(true, false))
  26. .then(browser => verifyBrowser(browser, true, false))
  27. .then(browser => makePrerenderedBrowserActive(browser))
  28. .then(browser => verifyBrowser(browser, false, false))
  29. // test remote, non-prerendered browser
  30. .then(() => createBrowser(false, true))
  31. .then(browser => verifyBrowser(browser, false, true))
  32. // test remote, prerendered browser
  33. .then(() => createBrowser(true, true))
  34. .then(browser => verifyBrowser(browser, true, true))
  35. .then(browser => makePrerenderedBrowserActive(browser))
  36. .then(browser => verifyBrowser(browser, false, true))
  37. // finish test
  38. .then(() => {
  39. opener.postMessage('finish', '*');
  40. window.close();
  41. });
  42. }
  43. function createBrowser(prerendered, remote) {
  44. return new Promise(resolve => {
  45. var browser = document.createElement('browser');
  46. browser.setAttribute('type', 'content');
  47. browser.setAttribute('prerendered', prerendered);
  48. browser.setAttribute('remote', remote);
  49. document.documentElement.appendChild(browser);
  50. browser.loadURI('example.com');
  51. resolve(browser);
  52. });
  53. }
  54. function verifyBrowser(browser, prerendered, remote) {
  55. var docShellOrTabParent = remote ?
  56. browser.frameLoader.tabParent : browser.frameLoader.docShell;
  57. ok(docShellOrTabParent, 'docShellOrTabParent should not be null');
  58. is(docShellOrTabParent.isPrerendered, prerendered,
  59. 'isPrerendered should be ' + prerendered);
  60. return browser;
  61. }
  62. function makePrerenderedBrowserActive(browser) {
  63. browser.makePrerenderedBrowserActive();
  64. return browser;
  65. }
  66. ]]>
  67. </script>
  68. <!-- <browser type="content-primary" flex="1" id="content" />
  69. <browser type="content-primary" flex="1" id="content-remote" remote="true" /> -->
  70. </window>