mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 11:37:43 -10:00
***
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
63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
// Ensure that the RDM container tab URL is not recorded in session history.
|
|
|
|
const TEST_URL = "http://example.com/";
|
|
const CONTAINER_URL = "chrome://devtools/content/responsive.html/index.xhtml";
|
|
|
|
const { TabStateFlusher } =
|
|
ChromeUtils.import("resource:///modules/sessionstore/TabStateFlusher.jsm");
|
|
const { OUTER_FRAME_LOADER_SYMBOL } =
|
|
require("devtools/client/responsive.html/browser/tunnel");
|
|
|
|
function flushContainerTabState(tab) {
|
|
const browser = tab.linkedBrowser;
|
|
const outerBrowser = {
|
|
permanentKey: browser.permanentKey,
|
|
messageManager: browser[OUTER_FRAME_LOADER_SYMBOL].messageManager,
|
|
};
|
|
// Try to flush the tab, but if that hangs for a while, resolve anyway.
|
|
// During this test, we actually expect this to hang because the container tab
|
|
// doesn't have the right epoch value to reply to the flush correctly.
|
|
return new Promise(resolve => {
|
|
TabStateFlusher.flush(outerBrowser).then(resolve);
|
|
waitForTime(10000).then(resolve);
|
|
});
|
|
}
|
|
|
|
add_task(async function() {
|
|
// Load test URL
|
|
const tab = await addTab(TEST_URL);
|
|
const browser = tab.linkedBrowser;
|
|
|
|
// Check session history state
|
|
let history = await getSessionHistory(browser);
|
|
is(history.index - 1, 0, "At page 0 in history");
|
|
is(history.entries.length, 1, "1 page in history");
|
|
is(history.entries[0].url, TEST_URL, "Page 0 URL matches");
|
|
|
|
// Open RDM
|
|
await openRDM(tab);
|
|
|
|
// Checking session history directly in content does show the container URL
|
|
// that we're trying to hide...
|
|
history = await getSessionHistory(browser);
|
|
is(history.index - 1, 0, "At page 0 in history");
|
|
is(history.entries.length, 1, "1 page in history");
|
|
is(history.entries[0].url, CONTAINER_URL, "Page 0 URL matches");
|
|
|
|
// However, checking the recorded tab state for the outer browser shows the
|
|
// container URL has been ignored correctly.
|
|
await flushContainerTabState(tab);
|
|
const tabState = JSON.parse(SessionStore.getTabState(tab));
|
|
is(tabState.index - 1, 0, "At page 0 in history");
|
|
is(tabState.entries.length, 1, "1 page in history");
|
|
is(tabState.entries[0].url, TEST_URL, "Page 0 URL matches");
|
|
|
|
await closeRDM(tab);
|
|
await removeTab(tab);
|
|
});
|