fune/toolkit/content/tests/chrome/test_navigate_persist.html
Kris Maglione e930b89c34 Bug 1514594: Part 3 - Change ChromeUtils.import API.
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8

This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:

  ChromeUtils.import("resource://gre/modules/Services.jsm");

is approximately the same as the following, in the new model:

  var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs

This was done using the followng script:

https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16750

--HG--
extra : rebase_source : 359574ee3064c90f33bf36c2ebe3159a24cc8895
extra : histedit_source : b93c8f42808b1599f9122d7842d2c0b3e656a594%2C64a3a4e3359dc889e2ab2b49461bab9e27fc10a7
2019-01-17 10:18:31 -08:00

78 lines
No EOL
2.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1460639
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1460639</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript">
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
function navigateWindowTo(win, url) {
return new Promise(resolve => {
Services.obs.addObserver(function listener(document) {
Services.obs.removeObserver(listener, "document-element-inserted");
document.addEventListener("DOMContentLoaded", () => {
resolve();
}, { once: true } );
}, "document-element-inserted");
win.location = url;
});
}
function resize(win, size) {
let resizePromise = new Promise(resolve => {
if (win.outerWidth === size && win.outerHeight === size) {
resolve();
}
win.addEventListener("resize", () => {
resolve();
}, {once: true});
});
win.resizeTo(size, size);
return resizePromise;
}
async function runTest() {
// Test that persisted window attributes are loaded when a top level
// window is navigated. This mimics the behavior of early first paint by
// first loading about:blank and then navigating to window_navigate_persist.html.
const PERSIST_SIZE = 200;
// First, load the document and resize it so the size is persisted.
let win = openDialog("window_navigate_persist.html", "_blank", `chrome,all,dialog=no`);
await SimpleTest.promiseFocus(win);
await resize(win, PERSIST_SIZE);
is(win.outerWidth, PERSIST_SIZE, "Window is resized to desired width");
is(win.outerHeight, PERSIST_SIZE, "Window is resized to desired height");
win.close();
// Now mimic early first paint.
win = openDialog("about:blank", "_blank", `chrome,all,dialog=no`);
await SimpleTest.promiseFocus(win, true);
isnot(win.outerWidth, PERSIST_SIZE, "Initial window width is not the persisted size");
isnot(win.outerHeight, PERSIST_SIZE, "Initial window height is not the persisted size");
await navigateWindowTo(win, "window_navigate_persist.html");
is(win.outerWidth, PERSIST_SIZE, "Window width is persisted");
is(win.outerHeight, PERSIST_SIZE, "Window height is persisted");
win.close();
SimpleTest.finish();
}
</script>
</head>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1460639">Mozilla Bug 1460639</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>