Merge mozilla-central to mozilla-inbound. a=merge

This commit is contained in:
Mihai Alexandru Michis 2019-08-05 18:57:16 +03:00
commit 53d19b15b1
91 changed files with 540 additions and 555 deletions

View File

@ -987,7 +987,6 @@ pref("app.productInfo.baseURL", "https://www.mozilla.org/firefox/features/");
// Name of alternate about: page for certificate errors (when undefined, defaults to about:neterror)
pref("security.alternate_certificate_error_page", "certerror");
pref("browser.security.newcerterrorpage.mitm.enabled", true);
pref("security.certerrors.recordEventTelemetry", true);
pref("security.certerrors.permanentOverride", true);
pref("security.certerrors.mitm.priming.enabled", true);
@ -1254,9 +1253,7 @@ pref("services.sync.prefs.sync.privacy.fuzzyfox.clockgrainus", false);
pref("services.sync.prefs.sync.privacy.sanitize.sanitizeOnShutdown", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.enabled", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.cryptomining.enabled", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.cryptomining.annotate.enabled", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.fingerprinting.enabled", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.fingerprinting.annotate.enabled", true);
pref("services.sync.prefs.sync.privacy.trackingprotection.pbmode.enabled", true);
pref("services.sync.prefs.sync.privacy.resistFingerprinting", true);
pref("services.sync.prefs.sync.privacy.reduceTimerPrecision", true);

View File

@ -902,7 +902,7 @@ var ThirdPartyCookies = {
};
var SocialTracking = {
PREF_ENABLED: "privacy.trackingprotection.socialtracking.annotate.enabled",
PREF_ENABLED: "privacy.socialtracking.block_cookies.enabled",
PREF_NOTIFICATION_UI_ENABLED: "privacy.socialtracking.notification.enabled",
PREF_SESSION_PAGELOAD_MIN:
"privacy.socialtracking.notification.session.pageload.min",

View File

@ -6,8 +6,6 @@
const TRACKING_PAGE =
"http://example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
const CM_PROTECTION_PREF = "privacy.trackingprotection.cryptomining.enabled";
const CM_ANNOTATION_PREF =
"privacy.trackingprotection.cryptomining.annotate.enabled";
let cmHistogram;
add_task(async function setup() {
@ -24,7 +22,7 @@ add_task(async function setup() {
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.fingerprinting.enabled", false],
["privacy.trackingprotection.fingerprinting.annotate.enabled", false],
["urlclassifier.features.fingerprinting.annotate.blacklistHosts", ""],
],
});
cmHistogram = Services.telemetry.getHistogramById(
@ -192,7 +190,6 @@ function testTelemetry(pagesVisited, pagesWithBlockableContent, hasException) {
add_task(async function test() {
Services.prefs.setBoolPref(CM_PROTECTION_PREF, true);
Services.prefs.setBoolPref(CM_ANNOTATION_PREF, true);
await testIdentityState(false);
await testIdentityState(true);
@ -201,5 +198,4 @@ add_task(async function test() {
await testSubview(true);
Services.prefs.clearUserPref(CM_PROTECTION_PREF);
Services.prefs.clearUserPref(CM_ANNOTATION_PREF);
});

View File

@ -6,8 +6,6 @@
const TRACKING_PAGE =
"http://example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
const FP_PROTECTION_PREF = "privacy.trackingprotection.fingerprinting.enabled";
const FP_ANNOTATION_PREF =
"privacy.trackingprotection.fingerprinting.annotate.enabled";
let fpHistogram;
add_task(async function setup() {
@ -24,7 +22,8 @@ add_task(async function setup() {
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.cryptomining.enabled", false],
["privacy.trackingprotection.cryptomining.annotate.enabled", false],
["urlclassifier.features.cryptomining.annotate.blacklistHosts", ""],
["urlclassifier.features.cryptomining.annotate.blacklistTables", ""],
],
});
fpHistogram = Services.telemetry.getHistogramById(
@ -191,7 +190,6 @@ function testTelemetry(pagesVisited, pagesWithBlockableContent, hasException) {
add_task(async function test() {
Services.prefs.setBoolPref(FP_PROTECTION_PREF, true);
Services.prefs.setBoolPref(FP_ANNOTATION_PREF, true);
await testIdentityState(false);
await testIdentityState(true);
@ -200,5 +198,4 @@ add_task(async function test() {
await testSubview(true);
Services.prefs.clearUserPref(FP_PROTECTION_PREF);
Services.prefs.clearUserPref(FP_ANNOTATION_PREF);
});

View File

@ -39,7 +39,6 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.trackingprotection.fingerprinting.annotate.enabled", true],
[
"urlclassifier.features.fingerprinting.blacklistHosts",
"fingerprinting.example.com",

View File

@ -9,8 +9,8 @@ const TRACKING_PAGE =
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.socialtracking.block_cookies.enabled", true],
["privacy.trackingprotection.socialtracking.enabled", true],
["privacy.trackingprotection.socialtracking.annotate.enabled", true],
[
"urlclassifier.features.socialtracking.blacklistHosts",
"socialtracking.example.com",
@ -22,9 +22,11 @@ add_task(async function setup() {
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.cryptomining.enabled", false],
["privacy.trackingprotection.cryptomining.annotate.enabled", false],
["urlclassifier.features.cryptomining.annotate.blacklistHosts", ""],
["urlclassifier.features.cryptomining.annotate.blacklistTables", ""],
["privacy.trackingprotection.fingerprinting.enabled", false],
["privacy.trackingprotection.fingerprinting.annotate.enabled", false],
["urlclassifier.features.fingerprinting.annotate.blacklistHosts", ""],
["urlclassifier.features.fingerprinting.annotate.blacklistTables", ""],
],
});
});

View File

@ -26,14 +26,11 @@
<hbox id="protections-popup-tp-switch-section" class="protections-popup-section">
<vbox class="protections-popup-tp-switch-label-box" flex="1">
<label class="protections-popup-tp-switch-on-header"
hidden="true">&protections.etpON.header;</label>
<label class="protections-popup-tp-switch-off-header"
hidden="true">&protections.etpOFF.header;</label>
<label class="protections-popup-tp-switch-on-header">&protections.etpON.header;</label>
<label class="protections-popup-tp-switch-off-header">&protections.etpOFF.header;</label>
<label id="protections-popup-tp-switch-breakage-link"
class="text-link"
onclick="gProtectionsHandler.showSiteNotWorkingView();"
hidden="true">&protections.siteNotWorking.label;</label>
onclick="gProtectionsHandler.showSiteNotWorkingView();">&protections.siteNotWorking.label;</label>
</vbox>
<vbox class="protections-popup-tp-switch-box">
<toolbarbutton id="protections-popup-tp-switch"

View File

@ -792,12 +792,15 @@ description#identity-popup-content-verifier,
opacity: 0.8;
}
#protections-popup[hasException] .protections-popup-tp-switch-on-header,
#protections-popup:not([hasException]) .protections-popup-tp-switch-off-header {
display: none;
}
#protections-popup-mainView-panel-header > description {
display: none;
}
#protections-popup:not([hasException]) .protections-popup-tp-switch-on-header,
#protections-popup[hasException] .protections-popup-tp-switch-off-header,
#protections-popup:not([hasException])[toast] #protections-popup-toast-panel-tp-on-desc,
#protections-popup[hasException][toast] #protections-popup-toast-panel-tp-off-desc {
display: unset;

View File

@ -216,12 +216,11 @@
/* Separator */
#tracking-protection-icon-container::after {
content: "";
border-right: 1px solid var(--lwt-background-tab-separator-color, currentColor);
border-right: 1px solid var(--urlbar-separator-color);
position: absolute;
right: 0;
top: 4px;
height: 21px;
opacity: .3;
}
#tracking-protection-icon-container:-moz-locale-dir(rtl)::after {

View File

@ -57,6 +57,13 @@ async function testReloadAboutDevToolsToolbox(toolId) {
await gDevTools.once("toolbox-ready");
ok(true, "Toolbox is re-created again");
// Check that about:devtools-toolbox is still selected tab. See Bug 1570692.
is(
devtoolsBrowser,
gBrowser.selectedBrowser,
"about:devtools-toolbox is still selected"
);
info("Check whether about:devtools-toolbox page displays correctly");
ok(
devtoolsBrowser.contentDocument.querySelector(".debug-target-info"),

View File

@ -137,12 +137,9 @@ DebuggerPanel.prototype = {
frames.forEach(frame => {
frame.actor = frame.id;
});
const target = this._client.lookupTarget(thread);
return { frames, selected };
},
lookupConsoleClient: function(thread) {
return this._client.lookupConsoleClient(thread);
return { frames, selected, target };
},
getMappedExpression(expression) {

View File

@ -5,7 +5,7 @@
// @flow
import { prepareSourcePayload, createWorker } from "./create";
import { supportsWorkers, updateWorkerClients } from "./workers";
import { supportsWorkers, updateWorkerTargets } from "./workers";
import { features } from "../../utils/prefs";
import Reps from "devtools-reps";
@ -40,7 +40,7 @@ import type {
EventListenerActiveList,
} from "../../actions/types";
let workerClients: Object;
let workerTargets: Object;
let threadFront: ThreadFront;
let tabTarget: TabTarget;
let debuggerClient: DebuggerClient;
@ -61,7 +61,7 @@ function setupCommands(dependencies: Dependencies) {
tabTarget = dependencies.tabTarget;
debuggerClient = dependencies.debuggerClient;
supportsWasm = dependencies.supportsWasm;
workerClients = {};
workerTargets = {};
sourceActors = {};
breakpoints = {};
}
@ -98,25 +98,23 @@ function sendPacket(packet: Object) {
return debuggerClient.request(packet);
}
function lookupThreadFront(thread: string) {
function lookupTarget(thread: string) {
if (thread == threadFront.actor) {
return threadFront;
return tabTarget;
}
if (!workerClients[thread]) {
throw new Error(`Unknown thread client: ${thread}`);
if (!workerTargets[thread]) {
throw new Error(`Unknown thread front: ${thread}`);
}
return workerClients[thread].thread;
return workerTargets[thread];
}
function lookupConsoleClient(thread: string) {
if (thread == threadFront.actor) {
return tabTarget.activeConsole;
}
return workerClients[thread].console;
function lookupThreadFront(thread: string) {
const target = lookupTarget(thread);
return target.threadFront;
}
function listWorkerThreadFronts() {
return (Object.values(workerClients): any).map(({ thread }) => thread);
return (Object.values(workerTargets): any).map(target => target.threadFront);
}
function forEachThread(iteratee) {
@ -253,9 +251,8 @@ function evaluate(
return Promise.resolve({ result: null });
}
const console = thread
? lookupConsoleClient(thread)
: tabTarget.activeConsole;
const target = thread ? lookupTarget(thread) : tabTarget;
const console = target.activeConsole;
if (!console) {
return Promise.resolve({ result: null });
}
@ -410,32 +407,32 @@ async function fetchWorkers(): Promise<Worker[]> {
observeAsmJS: true,
};
const newWorkerClients = await updateWorkerClients({
const newWorkerTargets = await updateWorkerTargets({
tabTarget,
debuggerClient,
threadFront,
workerClients,
workerTargets,
options,
});
// Fetch the sources and install breakpoints on any new workers.
const workerNames = Object.getOwnPropertyNames(newWorkerClients);
const workerNames = Object.getOwnPropertyNames(newWorkerTargets);
for (const actor of workerNames) {
if (!workerClients[actor]) {
const client = newWorkerClients[actor].thread;
if (!workerTargets[actor]) {
const front = newWorkerTargets[actor].threadFront;
// This runs in the background and populates some data, but we also
// want to allow it to fail quietly. For instance, it is pretty easy
// for source clients to throw during the fetch if their thread
// shuts down, and this would otherwise cause test failures.
getSources(client).catch(e => console.error(e));
getSources(front).catch(e => console.error(e));
}
}
workerClients = newWorkerClients;
workerTargets = newWorkerTargets;
return workerNames.map(actor =>
createWorker(actor, workerClients[actor].url)
createWorker(actor, workerTargets[actor].url)
);
}
@ -544,7 +541,7 @@ const clientCommands = {
getEventListenerBreakpointTypes,
detachWorkers,
hasWasmSupport,
lookupConsoleClient,
lookupTarget,
};
export { setupCommands, clientCommands };

View File

@ -197,6 +197,7 @@ export type Actions = {
export type TabTarget = {
on: (string, Function) => void,
emit: (string, any) => void,
threadFront: ThreadFront,
activeConsole: {
evaluateJS: (
script: Script,

View File

@ -11,26 +11,26 @@ export function supportsWorkers(tabTarget: TabTarget) {
return tabTarget.isBrowsingContext || tabTarget.isContentProcess;
}
export async function updateWorkerClients({
export async function updateWorkerTargets({
tabTarget,
debuggerClient,
threadFront,
workerClients,
workerTargets,
options,
}: Object) {
if (!supportsWorkers(tabTarget)) {
return {};
}
const newWorkerClients = {};
const newWorkerTargets = {};
const { workers } = await tabTarget.listWorkers();
for (const workerTargetFront of workers) {
try {
await workerTargetFront.attach();
const threadActorID = workerTargetFront._threadActor;
if (workerClients[threadActorID]) {
newWorkerClients[threadActorID] = workerClients[threadActorID];
if (workerTargets[threadActorID]) {
newWorkerTargets[threadActorID] = workerTargets[threadActorID];
} else {
const [, workerThread] = await workerTargetFront.attachThread(options);
workerThread.resume();
@ -40,11 +40,7 @@ export async function updateWorkerClients({
const consoleFront = await workerTargetFront.getFront("console");
await consoleFront.startListeners([]);
newWorkerClients[workerThread.actor] = {
url: workerTargetFront.url,
thread: workerThread,
console: consoleFront,
};
newWorkerTargets[workerThread.actor] = workerTargetFront;
}
} catch (e) {
// If any of the workers have terminated since the list command initiated
@ -52,5 +48,5 @@ export async function updateWorkerClients({
}
}
return newWorkerClients;
return newWorkerTargets;
}

View File

@ -352,8 +352,10 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
BrowserToolboxProcess.init();
break;
case "browserConsole":
const { HUDService } = require("devtools/client/webconsole/hudservice");
HUDService.openBrowserConsoleOrFocus();
const {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
BrowserConsoleManager.openBrowserConsoleOrFocus();
break;
case "responsiveDesignMode":
ResponsiveUIManager.toggle(window, window.gBrowser.selectedTab, {

View File

@ -25,8 +25,8 @@ loader.lazyRequireGetter(
);
loader.lazyRequireGetter(
this,
"HUDService",
"devtools/client/webconsole/hudservice",
"BrowserConsoleManager",
"devtools/client/webconsole/browser-console-manager",
true
);
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
@ -428,7 +428,7 @@ DevTools.prototype = {
* A SessionStore state object that gets modified by reference
*/
saveDevToolsSession: function(state) {
state.browserConsole = HUDService.getBrowserConsoleSessionState();
state.browserConsole = BrowserConsoleManager.getBrowserConsoleSessionState();
state.browserToolbox = BrowserToolboxProcess.getBrowserToolboxSessionState();
// Check if the module is loaded to avoid loading ScratchpadManager for no reason.
@ -458,8 +458,8 @@ DevTools.prototype = {
BrowserToolboxProcess.init();
}
if (browserConsole && !HUDService.getBrowserConsole()) {
HUDService.toggleBrowserConsole();
if (browserConsole && !BrowserConsoleManager.getBrowserConsole()) {
BrowserConsoleManager.toggleBrowserConsole();
}
},
@ -705,8 +705,10 @@ DevTools.prototype = {
* toolkit/components/extensions/ext-c-toolkit.js
*/
openBrowserConsole: function() {
const { HUDService } = require("devtools/client/webconsole/hudservice");
HUDService.openBrowserConsoleOrFocus();
const {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
BrowserConsoleManager.openBrowserConsoleOrFocus();
},
/**

View File

@ -76,8 +76,8 @@ loader.lazyRequireGetter(
);
loader.lazyRequireGetter(
this,
"HUDService",
"devtools/client/webconsole/hudservice",
"BrowserConsoleManager",
"devtools/client/webconsole/browser-console-manager",
true
);
loader.lazyRequireGetter(
@ -763,14 +763,18 @@ Toolbox.prototype = {
await promise.all([splitConsolePromise, framesPromise]);
// Request the actor to restore the focus to the content page once the
// target is detached. This typically happens when the console closes.
// We restore the focus as it may have been stolen by the console input.
await this.target.reconfigure({
options: {
restoreFocus: true,
},
});
// We do not expect the focus to be restored when using about:debugging toolboxes
// Otherwise, when reloading the toolbox, the debugged tab will be focused.
if (this.hostType !== Toolbox.HostType.PAGE) {
// Request the actor to restore the focus to the content page once the
// target is detached. This typically happens when the console closes.
// We restore the focus as it may have been stolen by the console input.
await this.target.reconfigure({
options: {
restoreFocus: true,
},
});
}
// Lazily connect to the profiler here and don't wait for it to complete,
// used to intercept console.profile calls before the performance tools are open.
@ -957,7 +961,7 @@ Toolbox.prototype = {
if (id == "browserConsole") {
// Add key for toggling the browser console from the detached window
shortcuts.on(electronKey, () => {
HUDService.toggleBrowserConsole();
BrowserConsoleManager.toggleBrowserConsole();
});
} else if (toolId) {
// KeyShortcuts contain tool-specific and global key shortcuts,

View File

@ -120,8 +120,10 @@ exports.menuitems = [
id: "menu_browserConsole",
l10nKey: "browserConsoleCmd",
oncommand() {
const { HUDService } = require("devtools/client/webconsole/hudservice");
HUDService.openBrowserConsoleOrFocus();
const {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
BrowserConsoleManager.openBrowserConsoleOrFocus();
},
keyId: "browserConsole",
},

View File

@ -127,8 +127,8 @@ loader.lazyRequireGetter(
);
loader.lazyRequireGetter(
this,
"HUDService",
"devtools/client/webconsole/hudservice",
"BrowserConsoleManager",
"devtools/client/webconsole/browser-console-manager",
true
);
loader.lazyRequireGetter(
@ -1586,7 +1586,7 @@ var Scratchpad = {
* Open the Error Console.
*/
openErrorConsole: function SP_openErrorConsole() {
HUDService.toggleBrowserConsole();
BrowserConsoleManager.toggleBrowserConsole();
},
/**

View File

@ -2,7 +2,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { HUDService } = require("devtools/client/webconsole/hudservice");
const {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
function test() {
waitForExplicitFinish();
@ -23,14 +25,14 @@ function runTests() {
Services.obs.removeObserver(observer, "web-console-created");
aSubject.QueryInterface(Ci.nsISupportsString);
const hud = HUDService.getBrowserConsole();
const hud = BrowserConsoleManager.getBrowserConsole();
ok(hud, "browser console is open");
is(aSubject.data, hud.hudId, "notification hudId is correct");
HUDService.toggleBrowserConsole().then(finish);
BrowserConsoleManager.toggleBrowserConsole().then(finish);
}, "web-console-created");
const hud = HUDService.getBrowserConsole();
const hud = BrowserConsoleManager.getBrowserConsole();
ok(!hud, "browser console is not open");
info("wait for the browser console to open from Scratchpad");

View File

@ -22,21 +22,20 @@ loader.lazyRequireGetter(
const BC_WINDOW_FEATURES =
"chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
function HUDService() {}
HUDService.prototype = {
_browserConsole: null,
_browserConsoleInitializing: null,
_browerConsoleSessionState: false,
class BrowserConsoleManager {
constructor() {
this._browserConsole = null;
this._browserConsoleInitializing = null;
this._browerConsoleSessionState = false;
}
storeBrowserConsoleSessionState() {
this._browerConsoleSessionState = !!this.getBrowserConsole();
},
}
getBrowserConsoleSessionState() {
return this._browerConsoleSessionState;
},
}
/**
* Open a Browser Console for the given target.
@ -52,14 +51,14 @@ HUDService.prototype = {
* A promise object for the opening of the new BrowserConsole instance.
*/
async openBrowserConsole(target, win, fissionSupport = false) {
const hud = new BrowserConsole(target, win, win, this, fissionSupport);
const hud = new BrowserConsole(target, win, win, fissionSupport);
this._browserConsole = hud;
hud.once("destroyed", () => {
this._browserConsole = null;
});
await hud.init();
return hud;
},
}
/**
* Toggle the Browser Console.
@ -147,7 +146,7 @@ HUDService.prototype = {
const browserConsole = await this._browserConsoleInitializing;
this._browserConsoleInitializing = null;
return browserConsole;
},
}
/**
* Opens or focuses the Browser Console.
@ -160,7 +159,7 @@ HUDService.prototype = {
}
return this.toggleBrowserConsole();
},
}
/**
* Get the Browser Console instance, if open.
@ -171,7 +170,7 @@ HUDService.prototype = {
*/
getBrowserConsole() {
return this._browserConsole;
},
};
}
}
exports.HUDService = new HUDService();
exports.BrowserConsoleManager = new BrowserConsoleManager();

View File

@ -10,8 +10,8 @@ var WebConsole = require("devtools/client/webconsole/webconsole");
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
loader.lazyRequireGetter(
this,
"HUDService",
"devtools/client/webconsole/hudservice",
"BrowserConsoleManager",
"devtools/client/webconsole/browser-console-manager",
true
);
@ -36,16 +36,8 @@ class BrowserConsole extends WebConsole {
* @param nsIDOMWindow chromeWindow
* The window of the browser console owner.
* @param Boolean fissionSupport
* @param object hudService
* The parent HUD Service
*/
constructor(
target,
iframeWindow,
chromeWindow,
hudService,
fissionSupport = false
) {
constructor(target, iframeWindow, chromeWindow, fissionSupport = false) {
super(target, iframeWindow, chromeWindow, true, fissionSupport);
this._telemetry = new Telemetry();
@ -131,7 +123,7 @@ var ShutdownObserver = {
observe(message, topic) {
if (topic == "quit-application-granted") {
HUDService.storeBrowserConsoleSessionState();
BrowserConsoleManager.storeBrowserConsoleSessionState();
this.uninit();
}
},

View File

@ -15,9 +15,9 @@ DIRS += [
'utils',
]
DevToolsModules(
'browser-console-manager.js',
'browser-console.js',
'constants.js',
'hudservice.js',
'panel.js',
'store.js',
'types.js',

View File

@ -28,7 +28,7 @@ add_task(async function() {
const opened = waitForBrowserConsole();
let hud = HUDService.getBrowserConsole();
let hud = BrowserConsoleManager.getBrowserConsole();
ok(!hud, "browser console is not open");
info("wait for the browser console to open with ctrl-shift-j");
EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window);

View File

@ -10,7 +10,7 @@ add_task(async function() {
// Show the content messages
await pushPref("devtools.browserconsole.contentMessages", true);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
await hud.ui.clearOutput();
await openNewTabAndConsole(
`data:text/html,<script>console.log("hello from content")</script>`

View File

@ -11,7 +11,7 @@ const TEST_URI = "data:text/html;charset=utf8,Test browser console clear cache";
add_task(async function() {
await pushPref("devtools.browserconsole.contentMessages", true);
await addTab(TEST_URI);
let hud = await HUDService.toggleBrowserConsole();
let hud = await BrowserConsoleManager.toggleBrowserConsole();
const CACHED_MESSAGE = "CACHED_MESSAGE";
await logTextToConsole(hud, CACHED_MESSAGE);
@ -29,8 +29,8 @@ add_task(async function() {
is(messages.length, 1, "There is only the new message in the output");
info("Close and re-open the browser console");
await HUDService.toggleBrowserConsole();
hud = await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
info("Log a smoke message in order to know that the console is ready");
await logTextToConsole(hud, "Smoke message");

View File

@ -14,7 +14,7 @@ const TEST_URI = "data:text/html;charset=utf8,<p>Bug 1296870";
add_task(async function() {
await loadTab(TEST_URI);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
info("Log a new message from the content page");
ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {

View File

@ -15,7 +15,7 @@ add_task(async function testCategoryLogs() {
const { console } = ChromeUtils.import("resource://gre/modules/Console.jsm");
console.log("bug861338-log-cached");
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
await checkMessageExists(hud, "bug861338-log-cached");
@ -49,7 +49,7 @@ add_task(async function testCategoryLogs() {
await checkMessageExists(hud, "foobarTimer");
hud.ui.clearOutput(true);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
});
add_task(async function testFilter() {
@ -61,7 +61,7 @@ add_task(async function testFilter() {
"resource://gre/modules/Console.jsm"
);
const console2 = new ConsoleAPI();
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
// Enable the error category and disable the log category.
await setFilterState(hud, {
@ -82,7 +82,7 @@ add_task(async function testFilter() {
await resetFilters(hud);
hud.ui.clearOutput(true);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
});
// Test that console.profile / profileEnd trigger the right events

View File

@ -17,7 +17,7 @@ add_task(async function() {
await pushPref("devtools.chrome.enabled", true);
await addTab(TEST_URI);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
info("Reload the content window to produce a network log");
const onNetworkMessage = waitForMessage(hud, "test-console.html");
@ -108,7 +108,7 @@ add_task(async function() {
await hideContextMenu(hud);
// Close the browser console.
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
});
function addPrefBasedEntries(expectedEntries) {

View File

@ -16,7 +16,7 @@ const {
add_task(async function() {
await addTab("about:blank");
const hud = await HUDService.openBrowserConsoleOrFocus();
const hud = await BrowserConsoleManager.openBrowserConsoleOrFocus();
const { message, actor } = await obtainObjectWithCPOW(hud);
await testFrontEnd(hud, message);

View File

@ -15,7 +15,7 @@
"use strict";
add_task(async function() {
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console opened");
// Add the reference to the nuked sandbox.

View File

@ -15,7 +15,7 @@ add_task(async function() {
const wcHud = await openNewTabAndConsole(TEST_URI);
ok(wcHud, "web console opened");
const bcHud = await HUDService.toggleBrowserConsole();
const bcHud = await BrowserConsoleManager.toggleBrowserConsole();
ok(bcHud, "browser console opened");
// Cause an exception in a script loaded with the DevTools loader.

View File

@ -16,7 +16,7 @@ add_task(async function() {
await pushPref("devtools.browserconsole.contentMessages", true);
await addTab(TEST_URI);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console opened");
// On e10s, the exception is triggered in child process

View File

@ -29,7 +29,7 @@ add_task(async function() {
await closeConsole();
info("web console closed");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console opened");
filterState = await getFilterState(hud);

View File

@ -14,7 +14,7 @@ add_task(async function() {
await pushPref("devtools.debugger.features.map-await-expression", true);
await addTab(TEST_URI);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
const executeAndWaitForResultMessage = (input, expectedOutput) =>
executeAndWaitForMessage(hud, input, expectedOutput, ".result");
@ -40,5 +40,5 @@ add_task(async function() {
);
info("Close the Browser console");
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
});

View File

@ -53,7 +53,7 @@ add_task(async function() {
await closeConsole();
info("web console closed");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console opened");
await waitFor(() => findMessage(hud, "cachedBrowserConsoleMessage"));

View File

@ -16,9 +16,9 @@ add_task(async function() {
const mainWindow = Services.wm.getMostRecentWindow(null);
await HUDService.openBrowserConsoleOrFocus();
await BrowserConsoleManager.openBrowserConsoleOrFocus();
hud = HUDService.getBrowserConsole();
hud = BrowserConsoleManager.getBrowserConsole();
ok(hud.ui.document.hasFocus(), "Focus in the document");
@ -33,14 +33,14 @@ add_task(async function() {
"The Browser Console is open and has focus"
);
mainWindow.focus();
await HUDService.openBrowserConsoleOrFocus();
await BrowserConsoleManager.openBrowserConsoleOrFocus();
currWindow = Services.wm.getMostRecentWindow(null);
is(
currWindow.document.documentURI,
Tools.webConsole.url,
"The Browser Console is open and has focus"
);
await HUDService.toggleBrowserConsole();
hud = HUDService.getBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
hud = BrowserConsoleManager.getBrowserConsole();
ok(!hud, "Browser Console has been closed");
});

View File

@ -10,21 +10,21 @@
add_task(async function() {
is(
HUDService.getBrowserConsoleSessionState(),
BrowserConsoleManager.getBrowserConsoleSessionState(),
false,
"Session state false by default"
);
HUDService.storeBrowserConsoleSessionState();
BrowserConsoleManager.storeBrowserConsoleSessionState();
is(
HUDService.getBrowserConsoleSessionState(),
BrowserConsoleManager.getBrowserConsoleSessionState(),
false,
"Session state still not true even after setting (since Browser Console is closed)"
);
await HUDService.toggleBrowserConsole();
HUDService.storeBrowserConsoleSessionState();
await BrowserConsoleManager.toggleBrowserConsole();
BrowserConsoleManager.storeBrowserConsoleSessionState();
is(
HUDService.getBrowserConsoleSessionState(),
BrowserConsoleManager.getBrowserConsoleSessionState(),
true,
"Session state true (since Browser Console is opened)"
);
@ -32,7 +32,7 @@ add_task(async function() {
info(
"Closing the browser console and waiting for the session restore to reopen it"
);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
const opened = waitForBrowserConsole();
gDevTools.restoreDevToolsSession({

View File

@ -34,7 +34,7 @@ add_task(async function() {
// Show the content messages
await pushPref("devtools.browserconsole.contentMessages", true);
const hud = await HUDService.toggleBrowserConsole();
const hud = await BrowserConsoleManager.toggleBrowserConsole();
hud.ui.clearOutput();
await addTab(TEST_URI);

View File

@ -61,7 +61,7 @@ add_task(async function() {
]);
info("promise.all resolved. start testing the Browser Console");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "Browser Console opened");
const deferred = defer();

View File

@ -29,7 +29,7 @@ add_task(async function() {
await closeConsole();
info("web console closed");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
await testBrowserConsole(hud);
await closeConsole();
});

View File

@ -71,7 +71,7 @@ add_task(async function() {
info("Test browser console");
await closeConsole(privateTab);
info("web console closed");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
// Make sure that the cached messages from private tabs are not displayed in the
// browser console.
@ -116,10 +116,10 @@ add_task(async function() {
assertNoPrivateMessages(hud);
info("close the browser console");
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
info("reopen the browser console");
hud = await HUDService.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console reopened");
assertNoPrivateMessages(hud);

View File

@ -32,7 +32,7 @@ add_task(async function() {
// in the test.
Services.prefs.setBoolPref("devtools.chrome.enabled", true);
browserConsole = await HUDService.toggleBrowserConsole();
browserConsole = await BrowserConsoleManager.toggleBrowserConsole();
objInspector = await logObject(browserConsole);
testJSTermIsVisible(browserConsole);
await testObjectInspectorPropertiesAreSet(objInspector);
@ -44,10 +44,10 @@ add_task(async function() {
await testObjectInspectorPropertiesAreSet(objInspector);
await closeConsole(browserTab);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
Services.prefs.setBoolPref("devtools.chrome.enabled", false);
browserConsole = await HUDService.toggleBrowserConsole();
browserConsole = await BrowserConsoleManager.toggleBrowserConsole();
objInspector = await logObject(browserConsole);
testJSTermIsNotVisible(browserConsole);
@ -58,7 +58,7 @@ add_task(async function() {
info("Close webconsole and browser console");
await closeConsole(browserTab);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
});
async function logObject(hud) {

View File

@ -28,7 +28,7 @@ add_task(async function() {
Services.console.registerListener(listener);
// trigger a lazy-load of the HUD Service
HUDService;
BrowserConsoleManager;
await sendRequestFromChrome();

View File

@ -36,7 +36,9 @@ Services.scriptloader.loadSubScript(
this
);
var { HUDService } = require("devtools/client/webconsole/hudservice");
var {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
var WCUL10n = require("devtools/client/webconsole/utils/l10n");
const DOCS_GA_PARAMS = `?${new URLSearchParams({
utm_source: "mozilla",
@ -60,10 +62,10 @@ registerCleanupFunction(async function() {
Services.prefs.getChildList("devtools.webconsole.filter").forEach(pref => {
Services.prefs.clearUserPref(pref);
});
const browserConsole = HUDService.getBrowserConsole();
const browserConsole = BrowserConsoleManager.getBrowserConsole();
if (browserConsole) {
browserConsole.ui.clearOutput(true);
await HUDService.toggleBrowserConsole();
await BrowserConsoleManager.toggleBrowserConsole();
}
});
@ -929,7 +931,7 @@ async function waitForBrowserConsole() {
Services.obs.removeObserver(observer, "web-console-created");
subject.QueryInterface(Ci.nsISupportsString);
const hud = HUDService.getBrowserConsole();
const hud = BrowserConsoleManager.getBrowserConsole();
ok(hud, "browser console is open");
is(subject.data, hud.hudId, "notification hudId is correct");

View File

@ -177,7 +177,7 @@ class WebConsoleWrapper {
return {
frameActor: grip.actor,
client: this.hud.lookupConsoleClient(grip.thread),
client: state.target.activeConsole,
};
},

View File

@ -274,18 +274,6 @@ class WebConsole {
return panel.getFrames();
}
/**
* Return the console client to use when interacting with a thread.
*
* @param {String} thread: The ID of the target thread.
* @returns {Object} The console client associated with the thread.
*/
lookupConsoleClient(thread) {
const toolbox = gDevTools.getToolbox(this.target);
const panel = toolbox.getPanel("jsdebugger");
return panel.lookupConsoleClient(thread);
}
/**
* Given an expression, returns an object containing a new expression, mapped by the
* parser worker to provide additional feature for the user (top-level await,

View File

@ -9,58 +9,54 @@ on the following diagram.
<figure class="hero">
<pre class="diagram">
┌───────────────────────────────────┐ ┌───────────────────────────────────┐
│ DevTools │ │ WebConsolePanel │
│ [client/framework/devtools.js] │ │ [panel.js] │
└───────────────────────────────────┘ └───────────────────────────────────┘
│ │
openBrowserConsole() or │
toggleBrowserConsole() │
│ │
▼ │
┌───────────────────────────────────┐ │
│ HUDService │ │
│ [hudservice.js] │ {hud}
└───────────────────────────────────┘ │
│ │
│ │
│ │
{_browserConsole} │
│ │
│ │
│ │
│ │
▼ 0..1 ▼ 1
┌────────────────────────┐ ┌────────────────────────┐
│ BrowserConsole │ │ WebConsole │
│ [browser-console.js] │─ ─ ─ ─ ─extends─ ─ ─ ▶│ [webconsole.js] │
└────────────────────────┘ └────────────────────────┘
{ui}
▼ 1
┌────────────────────────┐ ┌─────────────────────────────────┐
│ WebConsoleUI │ 1│ WebConsoleConnectionProxy │
│ [webconsole-ui.js] │─────{proxy}────────▶│[webconsole-connection-proxy.js] │
└────────────────────────┘ └─────────────────────────────────┘
│ │
{wrapper} │
│ │
▼ 1
┌────────────────────────┐ │
│ WebConsoleWrapper │
│[webconsole-wrapper.js] │◀ ─ ─ ─ ─ ─ ─ calls methods from─ ─ ─ ┘
└────────────────────────┘
<renders>
┌────────────────────────┐
│ App │
└────────────────────────┘
┌──────────────────────────────┐ ┌────────────────────────┐
│ DevTools │ │ WebConsolePanel │
│[client/framework/devtools.js]│ │ [panel.js] │
└──────────────────────────────┘ └────────────────────────┘
│ │
openBrowserConsole() or │
toggleBrowserConsole() │
│ │
▼ │
┌──────────────────────────────┐ {hud}
│ BrowserConsoleManager │ │
│ [browser-console-manager.js] │ │
└──────────────────────────────┘ │
│ │
│ │
{_browserConsole} │
│ │
▼ 0..1 ▼ 1
┌──────────────────────────────┐ ┌────────────────────────┐
│ BrowserConsole │ │ WebConsole │
│ [browser-console.js] │─ ─ extends ─ ▶│ [webconsole.js] │
└──────────────────────────────┘ └──────────────1─────────┘
{ui}
▼ 1
┌────────────────────────┐ ┌─────────────────────────────────┐
│ WebConsoleUI │ 1│ WebConsoleConnectionProxy │
│ [webconsole-ui.js] │───{proxy}──▶│[webconsole-connection-proxy.js] │
└────────────────────────┘ └─────────────────────────────────┘
│ │
{wrapper}
│ │
│ │
▼ 1
┌────────────────────────┐ │
│ WebConsoleWrapper │
│[webconsole-wrapper.js] │◀ ─ ─ ─calls methods from ─ ─ ┘
└────────────────────────┘
<renders>
┌────────────────────────┐
│ App │
└────────────────────────┘
</pre>
<figcaption>Elements between curly bracket on arrows represent the property name of the reference (for example, the WebConsolePanel as a `hud` property that is a reference to the WebConsole instance)</figcaption>
</figure>

View File

@ -882,8 +882,10 @@ DevToolsStartup.prototype = {
const window = Services.wm.getMostRecentWindow("devtools:webconsole");
if (!window) {
const require = this.initDevTools("CommandLine");
const { HUDService } = require("devtools/client/webconsole/hudservice");
HUDService.toggleBrowserConsole().catch(console.error);
const {
BrowserConsoleManager,
} = require("devtools/client/webconsole/browser-console-manager");
BrowserConsoleManager.toggleBrowserConsole().catch(console.error);
} else {
// the Browser Console was already open
window.focus();

View File

@ -44,9 +44,9 @@ const uint8_t MAX_CODE_BIT_LENGTH = 20;
const uint8_t MAX_PREFIX_BIT_LENGTH = 32;
// The length of the bit buffer, in bits.
const uint8_t BIT_BUFFER_LENGTH = 64;
const uint8_t BIT_BUFFER_SIZE = 64;
// Number of bits into the BIT_BUFFER_LENGTH read at each step.
// Number of bits into the `bitBuffer` read at each step.
const uint8_t BIT_BUFFER_READ_UNIT = 8;
// Hardcoded limits to avoid allocating too eagerly.
@ -1018,15 +1018,16 @@ JS::Result<Ok> BinASTTokenReaderContext::readHuffmanPrelude() {
return reader.run(HUFFMAN_STACK_INITIAL_CAPACITY);
}
BinASTTokenReaderContext::BitBuffer::BitBuffer() : bits(0), length(0) {
static_assert(sizeof(bits) * 8 == BIT_BUFFER_LENGTH,
"Expecting bitBuffer to match BIT_BUFFER_LENGTH");
BinASTTokenReaderContext::BitBuffer::BitBuffer() : bits(0), bitLength(0) {
static_assert(sizeof(bits) * 8 == BIT_BUFFER_SIZE,
"Expecting bitBuffer to match BIT_BUFFER_SIZE");
}
template <Compression C>
HuffmanLookup BinASTTokenReaderContext::BitBuffer::getHuffmanLookup() {
// Only keep the leading 32 bits.
const uint8_t bitLength = std::min<uint8_t>(length, MAX_PREFIX_BIT_LENGTH);
const uint8_t bitLength =
std::min<uint8_t>(this->bitLength, MAX_PREFIX_BIT_LENGTH);
const uint32_t bitsPrefix = bits & (uint64_t)0x00000000FFFFFFFF;
return HuffmanLookup(bitsPrefix, bitLength);
}
@ -1037,33 +1038,59 @@ BinASTTokenReaderContext::BitBuffer::advanceBitBuffer(
BinASTTokenReaderContext& owner, const uint8_t bitLength) {
// It should be impossible to call `advanceBitBuffer`
// with more bits than what we just handed out.
MOZ_ASSERT(bitLength <= this->length);
this->length -= bitLength;
// We're reading from the leading bits on. Since we have just read
// `bitLength` bits, we now need to shift everything else into
// position.
this->bits <<= bitLength;
if (length <= MAX_PREFIX_BIT_LENGTH) {
MOZ_ASSERT(bitLength <= this->bitLength);
// The algorithm is not intuitive, so consider an example, where the byte
// stream starts with `0b_HGFE_DCBA`, `0b_PONM_LKJI`, `0b_XWVU_TRSQ` (to keep
// things concise, in the example, we won't use the entire 64 bits).
//
// In each byte, bits are stored in the reverse order, so what we want
// is `0b_ABCD_EFGH`, `0b_IJML_MNOP`, `0b_QRST_UVWX`.
// For the example, let's assume that we have already read
// `0b_ABCD_EFGH`, `0b_IJKL_MNOP` into `bits`, so before the call to
// `advanceBitBuffer`, `bits` initially contains
// `0b_XXXX_XXXX__XXXX_XXXX__ABCD_EFGH__IJKL_MNOP`, where `X` are bits that
// are beyond `this->bitLength`
// 1. We have consumed a few bits from the bit buffer, say `ABC`.
// `bits` is now `0b_XXXX_XXXX__XXXX_XXXX__XXXD_EFGH__IJKL_MNOP`.
this->bitLength -= bitLength;
if (this->bitLength <= MAX_PREFIX_BIT_LENGTH) {
// Keys can be up to MAX_PREFIX_BIT_LENGTH bits long. If we have fewer bits
// available, it's time to reload. We'll try and get as close to 64 bits as
// possible.
while (length <= BIT_BUFFER_LENGTH - BIT_BUFFER_READ_UNIT) {
while (this->bitLength <= BIT_BUFFER_SIZE - BIT_BUFFER_READ_UNIT) {
// Let's try and pull one byte.
uint8_t byte;
uint32_t byteLen = 1;
MOZ_TRY((owner.readBuf<C, EndOfFilePolicy::BestEffort>(&byte, byteLen)));
if (byteLen < 1) {
uint32_t readLen = 1;
MOZ_TRY((owner.readBuf<C, EndOfFilePolicy::BestEffort>(&byte, readLen)));
if (readLen < 1) {
// Ok, nothing left to read.
break;
}
// We have just read one byte.
// Append it to `bits`.
MOZ_ASSERT(bits <= 0x00FFFFFFFFFFFFFF);
// 2. We have just read to `byte`, here `0b_XWVU_TSRQ`. Let's reverse
// `byte` into `0b_QRST_UVWX`.
const uint8_t reversedByte =
(byte & 0b10000000) >> 7 | (byte & 0b01000000) >> 5 |
(byte & 0b00100000) >> 3 | (byte & 0b00010000) >> 1 |
(byte & 0b00001000) << 1 | (byte & 0b00000100) << 3 |
(byte & 0b00000010) << 5 | (byte & 0b00000001) << 7;
// 3. Make space for these bits at the end of the stream
// so shift `bits` into
// `0b_XXXX_XXXX__XXXD_EFGH__IJKL_MNOP__0000_0000`.
this->bits <<= BIT_BUFFER_READ_UNIT;
this->bits += byte;
this->length += BIT_BUFFER_READ_UNIT;
MOZ_ASSERT(bits >> this->length == 0);
// 4. Finally, combine into.
// `0b_XXXX_XXXX__XXXD_EFGH__IJKL_MNOP__QRST_UVWX`.
this->bits += reversedByte;
this->bitLength += BIT_BUFFER_READ_UNIT;
MOZ_ASSERT(bits >> this->bitLength == 0);
// 4. Continue as long as we don't have enough bits.
}
}
@ -1314,9 +1341,6 @@ HuffmanEntry<const T*> HuffmanTableImpl<T, N>::lookup(HuffmanLookup key) const {
const uint32_t keyBits = key.leadingBits(iter.key.bitLength);
if (keyBits == iter.key.bits) {
// FIXME: keyBits are actually stored in the reverse order from the
// stream.
// FIXME: We need to reverse either the one or the other.
// Entry found.
return HuffmanEntry<const T*>(iter.key.bits, iter.key.bitLength,
&iter.value);

View File

@ -62,50 +62,71 @@ struct NormalizedInterfaceAndField {
// the returned `HuffmanKey` and consume as many bits from the bit stream.
struct HuffmanLookup {
HuffmanLookup(uint32_t bits, uint8_t bitLength)
: bits(bits), bitLength(bitLength) {
// We zero out the highest `32 - bitLength` bits.
: bits(bits & (uint32_t(0xFFFFFFFF) >> (32 - bitLength))),
bitLength(bitLength) {
MOZ_ASSERT(bitLength <= 32);
MOZ_ASSERT(bits >> bitLength == 0);
}
// Return the `bitLength` leading bits of this superset.
// This only makes sense if `bitLength <= this.bitLength`.
// Return the `bitLength` leading bits of this superset, in the order
// expected to compare to a `HuffmanKey`. The order of bits and bytes
// is ensured by `BitBuffer`.
//
// Note: This only makes sense if `bitLength <= this.bitLength`.
//
// So, for instance, if `leadingBits(4)` returns
// `0b_0000_0000__0000_0000__0000_0000__0000_0100`, this is
// equal to Huffman Key `0100`.
uint32_t leadingBits(const uint8_t bitLength) const;
// The buffer holding the bits.
// FIXME: Document bit order.
// The buffer holding the bits. At this stage, bits are stored
// in the same order as `HuffmanKey`. See the implementation of
// `BitBuffer` methods for more details about how this order
// is implemented.
//
// If `bitLength < 32`, the unused highest bits are guaranteed
// to be 0.
uint32_t bits;
// The actual length of buffer `bits`:
// - if `bitLength == 0`, use 0 bits of `bits`, this entire value is `0`;
// - if `bitLength == 1`, only use the last bit of `bits`;
// - ...
// - if `bitLength == 32`, use the entire value of `bits`;
// - other values of `bitLength` are invalid.
// The actual length of buffer `bits`.
//
// Invariant: the first `32 - bitLength` bits are always 0.
// MUST be within `[0, 32]`.
//
// If `bitLength < 32`, it means that some of the highest bits are unused.
uint8_t bitLength;
};
// A Huffman Key.
struct HuffmanKey {
HuffmanKey(uint32_t bits, uint8_t bitLength)
// Construct the HuffmanKey.
//
// `bits` and `bitLength` define a buffer containing the standard Huffman
// code for this key.
//
// For instance, if the Huffman code is `0100`,
// - `bits = 0b0000_0000__0000_0000__0000_0000__0000_0100`;
// - `bitLength = 4`.
HuffmanKey(const uint32_t bits, const uint8_t bitLength)
: bits(bits), bitLength(bitLength) {
MOZ_ASSERT(bitLength <= 32);
MOZ_ASSERT(bits >> bitLength == 0);
}
// The buffer holding the bits.
// FIXME: Document bit order.
//
// For a Huffman code of `0100`
// - `bits = 0b0000_0000__0000_0000__0000_0000__0000_0100`;
//
// If `bitLength < 32`, the unused highest bits are guaranteed
// to be 0.
uint32_t bits;
// The actual length of buffer `bits`:
// - if `bitLength == 0`, use 0 bits of `bits`, this entire value is `0`;
// - if `bitLength == 1`, only use the last bit of `bits`;
// - ...
// - if `bitLength == 32`, use the entire value of `bits`;
// - other values of `bitLength` are invalid.
// The actual length of buffer `bits`.
//
// Invariant: the first `32 - bitLength` bits are always 0.
// MUST be within `[0, 32]`.
//
// If `bitLength < 32`, it means that some of the highest bits are unused.
uint8_t bitLength;
};
@ -397,15 +418,30 @@ class MOZ_STACK_CLASS BinASTTokenReaderContext : public BinASTTokenReaderBase {
private:
// The contents of the buffer.
//
// - Bytes are added in the same order as the bytestream.
// - Individual bits within bytes are mirrored.
//
// In other words, if the byte stream starts with
// `0b_HGFE_DCBA`, `0b_PONM_LKJI`, `0b_0000_0000`,
// .... `0b_0000_0000`, `bits` will hold
// `0b_0000_...0000__ABCD_EFGH__IJKL_MNOP`.
//
// Note: By opposition to `HuffmanKey` or `HuffmanLookup`,
// the highest bits are NOT guaranteed to be `0`.
uint64_t bits;
// The number of elements in `bits`.
//
// Until we start lookup up into Huffman tables, `length == 0`.
// Until we start lookup up into Huffman tables, `bitLength == 0`.
// Once we do, we refill the buffer before any lookup, i.e.
// `length == 32` until we reach the last few bytes of the stream,
// `MAX_PREFIX_BIT_LENGTH = 32 <= bitLength <= BIT_BUFFER_SIZE = 64`
// until we reach the last few bytes of the stream,
// in which case `length` decreases monotonically to 0.
uint64_t length;
//
// If `bitLength < BIT_BUFFER_SIZE = 64`, some of the highest
// bits of `bits` are unused.
uint8_t bitLength;
} bitBuffer;
// The number of already decoded bytes.

View File

@ -5742,36 +5742,18 @@
value: false
mirror: always
# Annotate fingerprinting resources.
- name: privacy.trackingprotection.fingerprinting.annotate.enabled
type: bool
value: true
mirror: always
# Block 3rd party cryptomining resources.
- name: privacy.trackingprotection.cryptomining.enabled
type: bool
value: false
mirror: always
# Annotate cryptomining resources.
- name: privacy.trackingprotection.cryptomining.annotate.enabled
type: bool
value: true
mirror: always
# Block 3rd party socialtracking resources.
- name: privacy.trackingprotection.socialtracking.enabled
type: bool
value: false
mirror: always
# Annotate socialtracking resources.
- name: privacy.trackingprotection.socialtracking.annotate.enabled
type: bool
value: false
mirror: always
# Consider socialtracking annotation as trackers (see ETP)
- name: privacy.socialtracking.block_cookies.enabled
type: bool

View File

@ -529,15 +529,13 @@ interface nsIHttpChannel : nsIChannel
cenum ClassificationFlags : 32 {
/**
* The resource is on the fingerprinting list. This is only available if
* the privacy.trackingprotection.fingerprinting_annotate_enabled pref.
* The resource is on the fingerprinting list.
*/
CLASSIFIED_FINGERPRINTING = 0x0001,
CLASSIFIED_FINGERPRINTING_CONTENT = 0x0080,
/**
* The resource is on the cryptomining list. This is only available if
* the privacy.trackingprotection.cryptomining_annotate_enabled pref is set.
* The resource is on the cryptomining list.
*/
CLASSIFIED_CRYPTOMINING = 0x0002,
CLASSIFIED_CRYPTOMINING_CONTENT = 0x0100,
@ -557,10 +555,10 @@ interface nsIHttpChannel : nsIChannel
/**
* The following are about social tracking.
*/
CLASSIFIED_SOCIALTRACKING = 0x0100,
CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x0200,
CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x0400,
CLASSIFIED_SOCIALTRACKING_TWITTER = 0x0800,
CLASSIFIED_SOCIALTRACKING = 0x0200,
CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x0400,
CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x0800,
CLASSIFIED_SOCIALTRACKING_TWITTER = 0x1000,
/**
* This is exposed to help to identify tracking classification using the

View File

@ -8,7 +8,6 @@
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/net/UrlClassifierCommon.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
@ -88,11 +87,6 @@ UrlClassifierFeatureCryptominingAnnotation::MaybeCreate(nsIChannel* aChannel) {
("UrlClassifierFeatureCryptominingAnnotation: MaybeCreate for channel %p",
aChannel));
if (!StaticPrefs::
privacy_trackingprotection_cryptomining_annotate_enabled()) {
return nullptr;
}
if (!UrlClassifierCommon::ShouldEnableClassifier(aChannel)) {
return nullptr;
}

View File

@ -8,7 +8,6 @@
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/net/UrlClassifierCommon.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
@ -90,11 +89,6 @@ UrlClassifierFeatureFingerprintingAnnotation::MaybeCreate(
"%p",
aChannel));
if (!StaticPrefs::
privacy_trackingprotection_fingerprinting_annotate_enabled()) {
return nullptr;
}
if (!UrlClassifierCommon::ShouldEnableClassifier(aChannel)) {
return nullptr;
}

View File

@ -8,7 +8,6 @@
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/net/UrlClassifierCommon.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
@ -90,11 +89,6 @@ UrlClassifierFeatureSocialTrackingAnnotation::MaybeCreate(
"%p",
aChannel));
if (!StaticPrefs::
privacy_trackingprotection_socialtracking_annotate_enabled()) {
return nullptr;
}
if (!UrlClassifierCommon::ShouldEnableClassifier(aChannel)) {
return nullptr;
}

View File

@ -5,11 +5,11 @@
// Test very basic CDP features.
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_DOC = toDataURL("default-test-page");
add_task(async function testCDP() {
// Open a test page, to prevent debugging the random default page
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_DOC);
// Start the CDP server
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
@ -22,7 +22,7 @@ add_task(async function testCDP() {
target(list) {
// Ensure debugging the right target, i.e. the one for our test tab.
return list.find(target => {
return target.url == TEST_URI;
return target.url == TEST_DOC;
});
},
});
@ -66,8 +66,7 @@ add_task(async function testCDP() {
const navigatedWithinDocument = Page.navigatedWithinDocument();
const loadEventFired = Page.loadEventFired();
await Page.navigate({
url:
"data:text/html;charset=utf-8,test-page<script>console.log('foo');</script><script>'</script>",
url: toDataURL(`<script>console.log("foo")</script>`),
});
ok(true, "A new page has been loaded");

View File

@ -5,8 +5,6 @@
// Basic test for dispatch key event API with input type text
const TEST_URI = "data:text/html;charset=utf-8,<input type=text>";
// Map of key codes used in this test.
const KEYCODES = {
a: 65,
@ -37,7 +35,7 @@ add_task(async function() {
SpecialPowers.pushPrefEnv(options, resolve);
});
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setupForURL(toDataURL("<input>"));
is(gBrowser.selectedTab, tab, "Selected tab is the target tab");
const { Input } = client;

View File

@ -26,11 +26,11 @@
// This can be racy because Input.dispatchKeyEvent and window.myVariable = "newValue" run
// in different processes.
const PAGE_URI =
const PAGE_URL =
"http://example.com/browser/remote/test/browser/doc_input_dispatchKeyEvent_race.html";
add_task(async function() {
const { client, tab } = await setupTestForUri(PAGE_URI);
const { client, tab } = await setupForURL(PAGE_URL);
is(gBrowser.selectedTab, tab, "Selected tab is the target tab");
const { Input, Runtime } = client;

View File

@ -3,10 +3,8 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,<div>foo</div>";
add_task(async function testDispatchMouseEvent() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setupForURL(toDataURL("<div>foo</div>"));
const { Input } = client;

View File

@ -5,8 +5,6 @@
// Test very basic CDP features.
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
add_task(async function() {
// Start the CDP server
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));

View File

@ -5,14 +5,13 @@
// Test the Network.requestWillBeSent event
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const PAGE_URI =
const PAGE_URL =
"http://example.com/browser/remote/test/browser/doc_network_requestWillBeSent.html";
const JS_URI =
const JS_URL =
"http://example.com/browser/remote/test/browser/file_network_requestWillBeSent.js";
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setupForURL(toDataURL("default-test-page"));
const { Page, Network } = client;
@ -25,7 +24,7 @@ add_task(async function() {
ok(true, "Received a request");
switch (++requests) {
case 1:
is(event.request.url, PAGE_URI, "Got the page request");
is(event.request.url, PAGE_URL, "Got the page request");
is(event.type, "Document", "The page request has 'Document' type");
is(
event.requestId,
@ -34,7 +33,7 @@ add_task(async function() {
);
break;
case 2:
is(event.request.url, JS_URI, "Got the JS request");
is(event.request.url, JS_URL, "Got the JS request");
resolve();
break;
case 3:
@ -43,7 +42,7 @@ add_task(async function() {
});
});
const { frameId } = await Page.navigate({ url: PAGE_URI });
const { frameId } = await Page.navigate({ url: PAGE_URL });
ok(frameId, "Page.navigate returned a frameId");
info("Wait for Network.requestWillBeSent events");

View File

@ -3,17 +3,17 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const OTHER_URI = "data:text/html;charset=utf-8,some-other-page";
const FIRST_DOC = toDataURL("first");
const SECOND_DOC = toDataURL("second");
add_task(async function testBringToFrontUpdatesSelectedTab() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setupForURL(FIRST_DOC);
is(gBrowser.selectedTab, tab, "Selected tab is the target tab");
info("Open another tab that should become the front tab");
const otherTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
OTHER_URI
SECOND_DOC
);
is(gBrowser.selectedTab, otherTab, "Selected tab is now the new tab");
@ -35,7 +35,7 @@ add_task(async function testBringToFrontUpdatesSelectedTab() {
});
add_task(async function testBringToFrontUpdatesFocusedWindow() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setupForURL(FIRST_DOC);
is(gBrowser.selectedTab, tab, "Selected tab is the target tab");
is(tab.ownerGlobal, getFocusedNavigator(), "The initial window is focused");

View File

@ -5,13 +5,13 @@
// Test the Page navigation events
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_DOC = toDataURL("default-test-page");
const promises = new Set();
const resolutions = new Map();
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setupForURL(TEST_DOC);
const { Page } = client;
@ -23,7 +23,7 @@ add_task(async function() {
ok(!!frameTree.frame, "getFrameTree exposes one frame");
is(frameTree.childFrames.length, 0, "getFrameTree reports no child frame");
ok(frameTree.frame.id, "getFrameTree's frame has an id");
is(frameTree.frame.url, TEST_URI, "getFrameTree's frame has the right url");
is(frameTree.frame.url, TEST_DOC, "getFrameTree's frame has the right url");
// Save the given `promise` resolution into the `promises` global Set
function recordPromise(name, promise) {

View File

@ -5,7 +5,6 @@
// Test that frameNavigated is not fired for iframes embedded in the page.
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const PAGE_URL =
"http://example.com/browser/remote/test/browser/doc_page_frameNavigated_iframe.html";
@ -13,7 +12,7 @@ const promises = new Set();
const resolutions = new Map();
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setupForURL(toDataURL("default-test-page"));
const { Page } = client;
await Page.enable();

View File

@ -3,12 +3,10 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// Test a browser alert is detected via Page.javascriptDialogOpening and can be
// closed with Page.handleJavaScriptDialog
add_task(async function() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setup();
const { Page } = client;

View File

@ -3,8 +3,6 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// Test beforeunload dialog events.
add_task(async function() {
info("Allow to trigger onbeforeunload without user interaction");
@ -15,7 +13,7 @@ add_task(async function() {
SpecialPowers.pushPrefEnv(options, resolve);
});
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setup();
const { Page } = client;

View File

@ -3,12 +3,10 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// Test for window.confirm(). Check that the dialog is correctly detected and that it can
// be rejected or accepted.
add_task(async function() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setup();
const { Page } = client;

View File

@ -3,13 +3,13 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const OTHER_URI = "data:text/html;charset=utf-8,other-test-page";
const FIRST_DOC = toDataURL("default-test-page");
const SECOND_DOC = toDataURL("other-test-page");
// Test that javascript dialog events are emitted by the page domain only if
// the dialog is created for the window of the target.
add_task(async function() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setupForURL(FIRST_DOC);
const { Page } = client;
@ -24,7 +24,7 @@ add_task(async function() {
info("Open another tab");
const otherTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
OTHER_URI
SECOND_DOC
);
is(gBrowser.selectedTab, otherTab, "Selected tab is now the new tab");

View File

@ -3,12 +3,10 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// Test for window.prompt(). Check that the dialog is correctly detected and that it can
// be rejected or accepted, with a custom prompt text.
add_task(async function() {
const { client, tab } = await setupTestForUri(TEST_URI);
const { client, tab } = await setup();
const { Page } = client;

View File

@ -5,12 +5,13 @@
/* global getCDP */
// Assert the order of Runtime.executionContextDestroyed, Page.frameNavigated and Runtime.executionContextCreated
// Assert the order of Runtime.executionContextDestroyed,
// Page.frameNavigated, and Runtime.executionContextCreated
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_DOC = toDataURL("default-test-page");
add_task(async function testCDP() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setupForURL(TEST_DOC);
const { Page, Runtime } = client;
const events = [];
@ -52,7 +53,7 @@ add_task(async function testCDP() {
ok(!!frameTree.frame, "getFrameTree exposes one frame");
is(frameTree.childFrames.length, 0, "getFrameTree reports no child frame");
ok(!!frameTree.frame.id, "getFrameTree's frame has an id");
is(frameTree.frame.url, TEST_URI, "getFrameTree's frame has the right url");
is(frameTree.frame.url, TEST_DOC, "getFrameTree's frame has the right url");
is(
frameTree.frame.id,
context.auxData.frameId,
@ -62,7 +63,7 @@ add_task(async function testCDP() {
const onFrameNavigated = Page.frameNavigated();
const onExecutionContextDestroyed = Runtime.executionContextDestroyed();
const onExecutionContextCreated2 = Runtime.executionContextCreated();
const url = "data:text/html;charset=utf-8,test-page";
const url = toDataURL("test-page");
const { frameId } = await Page.navigate({ url });
ok(true, "A new page has been loaded");
ok(frameId, "Page.navigate returned a frameId");

View File

@ -4,12 +4,10 @@
"use strict";
// Test the Runtime.callFunctionOn
// Also see browser_runtime_evaluate as it covers basic usages of this method.
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// See also browser_runtime_evaluate, which covers basic usages of this method.
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setup();
const firstContext = await testRuntimeEnable(client);
const contextId = firstContext.id;

View File

@ -5,11 +5,11 @@
// Test the Runtime execution context events
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_DOC = toDataURL("default-test-page");
add_task(async function() {
// Open a test page, to prevent debugging the random default page
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_DOC);
// Start the CDP server
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
@ -21,7 +21,7 @@ add_task(async function() {
const client = await CDP({
target(list) {
// Ensure debugging the right target, i.e. the one for our test tab.
return list.find(target => target.url == TEST_URI);
return list.find(target => target.url == TEST_DOC);
},
});
ok(true, "CDP client has been instantiated");
@ -122,7 +122,7 @@ async function testEvaluate({ Runtime }) {
const { result } = await Runtime.evaluate({ expression: "location.href" });
is(
result.value,
TEST_URI,
TEST_DOC,
"Runtime.evaluate works against the current document"
);
}
@ -134,7 +134,7 @@ async function testEvaluateWithContextId({ Runtime }, contextId) {
});
is(
result.value,
TEST_URI,
TEST_DOC,
"Runtime.evaluate works against the targetted document"
);
}
@ -158,7 +158,7 @@ async function testCallFunctionOn({ Runtime }, executionContextId) {
});
is(
result.value,
TEST_URI,
TEST_DOC,
"Runtime.callFunctionOn works and is against the test page"
);
}

View File

@ -5,10 +5,10 @@
// Test the Runtime execution context events
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_DOC = toDataURL("default-test-page");
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setupForURL(TEST_DOC);
const firstContext = await testRuntimeEnable(client);
await testEvaluate(client, firstContext);
@ -48,7 +48,7 @@ async function testEvaluate({ Runtime }, previousContext) {
});
is(
result.value,
TEST_URI,
TEST_DOC,
"Runtime.evaluate works and is against the test page"
);
}
@ -59,8 +59,7 @@ async function testNavigate({ Runtime, Page }, previousContext) {
const executionContextDestroyed = Runtime.executionContextDestroyed();
const executionContextCreated = Runtime.executionContextCreated();
const url = "data:text/html;charset=utf-8,test-page";
const { frameId } = await Page.navigate({ url });
const { frameId } = await Page.navigate({ url: toDataURL("test-page") });
ok(true, "A new page has been loaded");
is(
frameId,
@ -136,7 +135,7 @@ async function testNavigateBack({ Runtime }, firstContext, previousContext) {
});
is(
result.value,
TEST_URI,
TEST_DOC,
"Runtime.evaluate works and is against the page we just navigated to"
);
}
@ -147,7 +146,7 @@ async function testNavigateViaLocation({ Runtime }, previousContext) {
const executionContextDestroyed = Runtime.executionContextDestroyed();
const executionContextCreated = Runtime.executionContextCreated();
const url2 = "data:text/html;charset=utf-8,test-page-2";
const url2 = toDataURL("test-page-2");
await Runtime.evaluate({
contextId: previousContext.id,
expression: `window.location = '${url2}';`,

View File

@ -5,10 +5,8 @@
// Test the Runtime remote object
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setup();
const firstContext = await testRuntimeEnable(client);
const contextId = firstContext.id;

View File

@ -5,10 +5,8 @@
// Test the Runtime remote object
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
add_task(async function() {
const { client } = await setupTestForUri(TEST_URI);
const { client } = await setup();
const firstContext = await testRuntimeEnable(client);
const contextId = firstContext.id;

View File

@ -5,7 +5,7 @@
// Test very basic CDP features.
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
const TEST_URL = toDataURL("default-test-page");
add_task(async function() {
// Start the CDP server
@ -16,7 +16,7 @@ add_task(async function() {
// Use gBrowser.addTab instead of BrowserTestUtils as it creates the tab differently.
// It demonstrates a race around tab.linkedBrowser.browsingContext being undefined
// when accessing this property early.
const tab = gBrowser.addTab(TEST_URI, {
const tab = gBrowser.addTab(TEST_URL, {
skipAnimation: true,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
@ -25,7 +25,7 @@ add_task(async function() {
let targets = await getTargets(CDP);
ok(
targets.some(target => target.url == TEST_URI),
targets.some(target => target.url == TEST_URL),
"Found the tab in target list"
);
@ -33,7 +33,7 @@ add_task(async function() {
targets = await getTargets(CDP);
ok(
!targets.some(target => target.url == TEST_URI),
!targets.some(target => target.url == TEST_URL),
"Tab has been removed from the target list"
);

View File

@ -86,7 +86,7 @@ add_task(async function() {
id,
method: "Page.navigate",
params: {
url: "data:text/html;charset=utf-8,new-page",
url: toDataURL("new-page"),
},
});
await Target.sendMessageToTarget({ sessionId, message });

View File

@ -3,8 +3,6 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
// Test the Target closeTarget method and the targetDestroyed event.
add_task(async function() {
info("Start the CDP server");
@ -31,7 +29,10 @@ add_task(async function() {
info("Create a new tab and wait for the target to be created");
const otherTargetCreated = Target.targetCreated();
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
toDataURL("")
);
const { targetInfo } = await otherTargetCreated;
is(targetInfo.type, "page");

View File

@ -102,32 +102,50 @@ function getTargets(CDP) {
}
/**
* Create a new tab for the provided uri and start a CDP server debugging the
* created tab.
* Set up test environment in same fashion as setupForURL(),
* except using an empty document.
*/
async function setupTestForUri(uri) {
// Open a test page, to prevent debugging the random default page
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri);
async function setup() {
return setupForURL(toDataURL(""));
}
/**
* Set up test environment by starting the remote agent, connecting
* the CDP client over loopback, and creating a fresh tab to avoid
* state bleedover from previous test.
*/
async function setupForURL(url) {
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
// Start the CDP server
await RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
// Retrieve the chrome-remote-interface library object
const CDP = await getCDP();
// Connect to the server
const client = await CDP({
target(list) {
// Ensure debugging the right target, i.e. the one for our test tab.
return list.find(target => {
return target.url == uri;
});
// ensure we are debugging the right target, i.e. the requested URL
return list.find(target => target.url == url);
},
});
ok(true, "CDP client has been instantiated");
info("CDP client instantiated");
return { client, tab };
}
/** Creates a data URL for the given source document. */
function toDataURL(src, doctype = "html") {
let doc, mime;
switch (doctype) {
case "html":
mime = "text/html;charset=utf-8";
doc = `<!doctype html>\n<meta charset=utf-8>\n${src}`;
break;
default:
throw new Error("Unexpected doctype: " + doctype);
}
return `data:${mime},${encodeURIComponent(doc)}`;
}
/**
* Retrieve the value of a property on the content window.
*/

View File

@ -80,7 +80,7 @@ talos-damp:
by-test-platform:
linux64-ccov/.*: ['try'] # Bug 1407593
windows10-64-ccov/.*: ['try']
windows7-32/.*: ['try']
windows7-32(?:-shippable)?/.*: ['try']
(?:windows10-64|linux64)(?:-qr)?/opt: ['mozilla-central', 'try']
windows10-aarch64/opt: ['try'] # Bug 1544360
macosx.*64(?:-shippable)?(?:-qr)?/opt: ['mozilla-central', 'try']

View File

@ -46,10 +46,10 @@
},
"arrow": {
"hashes": [
"sha256:20055cd5dd03314c62544138a227ba24fb040b949e7cf785da611d3d4b11d31c",
"sha256:33eb1599b93466daa5aba34a70b2507dbe2ce37a5b4cf23608ff2b7d52846132"
"sha256:157dee94b557ffe9a2e13e05669bf48820064cb37d416f547f59baa0d25301d4",
"sha256:47f37968afeaefd0ba3fe4d0c70dc830985f9ab11beeb381d4fc0e8f8151d3d6"
],
"version": "==0.14.3"
"version": "==0.14.4"
},
"asn1crypto": {
"hashes": [
@ -74,11 +74,11 @@
},
"awscli": {
"hashes": [
"sha256:2063159a462194c2093538402b3a280dc7b5485bda0908cace64f7645d13c828",
"sha256:e1211905f99f5ca94084949ff3b5d513905070b20d112aedeedea4d8ad56ce87"
"sha256:413ad43c8b8c550243086e3b58e33870ecd8efca2094e4308ce4c5b1b09967b4",
"sha256:53c1b76bea0e5b6e60ae85195ea5ed9d62fa7f425310c7d3f20cd02cfd1f5bd9"
],
"index": "pypi",
"version": "==1.16.207"
"version": "==1.16.210"
},
"backports.lzma": {
"hashes": [
@ -88,10 +88,10 @@
},
"botocore": {
"hashes": [
"sha256:6e7c49014430f73ba6ab638d4ad313f8522b8185e476fe1a57ce9cd50c596062",
"sha256:78627966a280328e4a7018758e91e6413d5cae8387e08ab219e232689a92cb45"
"sha256:9448deffdb58e852935eeaae90682b7a0b4ef3c45eb6f17fa4444873f45f9ae6",
"sha256:d2ead76e77e7d0cd4c6bf9445e0ff54e279aee3c727eb30255b4ec327f956d22"
],
"version": "==1.12.197"
"version": "==1.12.200"
},
"certifi": {
"hashes": [
@ -238,10 +238,10 @@
},
"jsonschema": {
"hashes": [
"sha256:0c0a81564f181de3212efa2d17de1910f8732fa1b71c42266d983cd74304e20d",
"sha256:a5f6559964a3851f59040d3b961de5e68e70971afb88ba519d27e6a039efff1a"
"sha256:5f9c0a719ca2ce14c5de2fd350a64fd2d13e8539db29836a86adc990bb1a068f",
"sha256:8d4a2b7b6c2237e0199c8ea1a6d3e05bf118e289ae2b9d7ba444182a2959560d"
],
"version": "==3.0.1"
"version": "==3.0.2"
},
"jwcrypto": {
"hashes": [
@ -301,10 +301,10 @@
},
"pyasn1": {
"hashes": [
"sha256:da2420fe13a9452d8ae97a0e478adde1dee153b11ba832a95b223a2ba01c10f7",
"sha256:da6b43a8c9ae93bc80e2739efb38cc776ba74a886e3e9318d65fe81a8b8a2c6e"
"sha256:3bb81821d47b17146049e7574ab4bf1e315eb7aead30efe5d6a9ca422c9710be",
"sha256:b773d5c9196ffbc3a1e13bdf909d446cad80a039aa3340bcad72f395b76ebc86"
],
"version": "==0.4.5"
"version": "==0.4.6"
},
"pycparser": {
"hashes": [
@ -375,11 +375,11 @@
},
"scriptworker": {
"hashes": [
"sha256:15fc54f744fea425d82e5d16be15f4622824156e00949f64abfe18fad7568dfb",
"sha256:db725e7ff2167201d7a287c43659dfdbac9efa1b846c262c745866467628ce0b"
"sha256:3dae59ac6e6bbacd7c933b1c84f32b7b1d2b5bd821d9e80097a78ef8b2590cfa",
"sha256:48fb7333c160ac2b0ca02c5bb8df141c8b12102a94ca0453529dc3dfc553239a"
],
"index": "pypi",
"version": "==23.6.1"
"version": "==23.6.2"
},
"sh": {
"hashes": [
@ -405,11 +405,11 @@
},
"taskcluster": {
"hashes": [
"sha256:3d5f080cf6c27772983dfa3945ad558d1f7d35f5bcdd483cfd2b704aa2180f85",
"sha256:4e4a0348cbe29bf54a7354e67968bc0d8a00e2376d9be37c82b6d0095d9d9341",
"sha256:78d30dc38526ce2cce051b0acecc40021130f8a4d4829cc1a11836ca40a48cd9"
"sha256:2846eb270a9c563ff2e0fbfc69999bbcc4b9e33979206d5433fd1eeba11f6785",
"sha256:8ac7b25c28138b4c1b01614e272f5558ff2af79d4e01430c32ca407838923467",
"sha256:f2ae5cd1f89f6ca3ab869b71b35158e762decc904f5bf483a4ea4843f75a7ef5"
],
"version": "==15.0.0"
"version": "==16.0.0"
},
"taskcluster-urls": {
"hashes": [

View File

@ -1,7 +1,4 @@
[movementX_Y_basic.html]
expected:
if os == "win": ERROR
if os == "mac": ERROR
[Test that movementX/Y = eNow.screenX/Y-ePrevious.screenX/Y.]
expected:
if not e10s: FAIL

View File

@ -128,8 +128,8 @@
}
function run_test() {
x = window.innerWidth / 2;
y = window.innerHeight / 2;
x = Math.round(window.innerWidth / 2);
y = Math.round(window.innerHeight / 2);
var actions = new test_driver.Actions();
actions.pointerMove(x, y)
.pointerDown()

View File

@ -12,7 +12,6 @@ function runTest(obj) {
["privacy.trackingprotection.annotate_channels", true],
["privacy.storagePrincipal.enabledForTrackers", false],
["urlclassifier.features.socialtracking.annotate.blacklistHosts", "not-tracking.example.com"],
["privacy.trackingprotection.socialtracking.annotate.enabled", obj.annotationEnabled],
["urlclassifier.features.socialtracking.blacklistHosts", "not-tracking.example.com"],
["privacy.trackingprotection.socialtracking.enabled", obj.protectionEnabled],
["privacy.socialtracking.block_cookies.enabled", obj.cookieBlocking],
@ -75,18 +74,8 @@ function runTest(obj) {
});
}
runTest({
testName: "Socialtracking-annotation feature not enabled",
annotationEnabled: false,
protectionEnabled: false,
loading: true,
cookieBlocking: false,
result: true,
});
runTest({
testName: "Socialtracking-annotation feature enabled but not considered for tracking detection.",
annotationEnabled: true,
protectionEnabled: false,
loading: true,
cookieBlocking: false,
@ -95,7 +84,6 @@ runTest({
runTest({
testName: "Socialtracking-annotation feature enabled and considered for tracking detection.",
annotationEnabled: true,
protectionEnabled: false,
loading: true,
cookieBlocking: true,
@ -104,7 +92,6 @@ runTest({
runTest({
testName: "Socialtracking-protection feature enabled.",
annotationEnabled: true,
protectionEnabled: true,
loading: false,
cookieBlocking: true,

View File

@ -1,81 +1,84 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebExtension test</title>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<head>
<title>WebExtension test</title>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script src="head.js" type="text/javascript"></script>
<link href="/tests/SimpleTest/test.css" rel="stylesheet"/>
</head>
<body>
<script type="text/javascript">
"use strict";
<script type="text/javascript">
"use strict";
/* eslint-disable mozilla/balanced-listeners */
/* eslint-disable mozilla/balanced-listeners */
add_task(async function testAlertNotShownInBackgroundWindow() {
let extension = ExtensionTestUtils.loadExtension({
background: function() {
alert("I am an alert in the background.");
add_task(async function testAlertNotShownInBackgroundWindow() {
let extension = ExtensionTestUtils.loadExtension({
background: function () {
alert("I am an alert in the background.");
browser.test.notifyPass("alertCalled");
},
});
browser.test.notifyPass("alertCalled");
}
});
let consoleOpened = loadChromeScript(() => {
const {sendAsyncMessage, assert} = this;
assert.ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(),
"Alerts should not be present at the start of the test.");
let consoleOpened = loadChromeScript(() => {
const {sendAsyncMessage, assert} = this;
assert.ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(), "Alerts should not be present at the start of the test.");
Services.obs.addObserver(function observer() {
sendAsyncMessage("web-console-created");
Services.obs.removeObserver(observer, "web-console-created");
}, "web-console-created");
});
let opened = consoleOpened.promiseOneMessage("web-console-created");
Services.obs.addObserver(function observer() {
sendAsyncMessage("web-console-created");
Services.obs.removeObserver(observer, "web-console-created");
}, "web-console-created");
});
let opened = consoleOpened.promiseOneMessage("web-console-created");
consoleMonitor.start([{message: /alert\(\) is not supported in background windows/},
{message: /I am an alert in the background/}]);
consoleMonitor.start([
{
message: /alert\(\) is not supported in background windows/
}, {
message: /I am an alert in the background/
}
]);
await extension.startup();
await extension.awaitFinish("alertCalled");
await extension.startup();
await extension.awaitFinish("alertCalled");
let chromeScript = loadChromeScript(async () => {
const {assert} = this;
assert.ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(),
"Alerts should not be present after calling alert().");
});
chromeScript.destroy();
let chromeScript = loadChromeScript(async () => {
const {assert} = this;
assert.ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(), "Alerts should not be present after calling alert().");
});
chromeScript.destroy();
await consoleMonitor.finished();
await consoleMonitor.finished();
await opened;
consoleOpened.destroy();
await opened;
consoleOpened.destroy();
chromeScript = loadChromeScript(async () => {
const {sendAsyncMessage} = this;
let {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
require("devtools/client/framework/devtools-browser");
let {HUDService} = require("devtools/client/webconsole/hudservice");
chromeScript = loadChromeScript(async () => {
const {sendAsyncMessage} = this;
let {require} = ChromeUtils.import ("resource://devtools/shared/Loader.jsm");
require("devtools/client/framework/devtools-browser");
let {BrowserConsoleManager} = require("devtools/client/webconsole/browser-console-manager");
// And then double check that we have an actual browser console.
let haveConsole = !!HUDService.getBrowserConsole();
// And then double check that we have an actual browser console.
let haveConsole = !!BrowserConsoleManager.getBrowserConsole();
if (haveConsole) {
await HUDService.toggleBrowserConsole();
}
sendAsyncMessage("done", haveConsole);
});
if (haveConsole) {
await BrowserConsoleManager.toggleBrowserConsole();
}
sendAsyncMessage("done", haveConsole);
});
let consoleShown = await chromeScript.promiseOneMessage("done");
ok(consoleShown, "console was shown");
chromeScript.destroy();
let consoleShown = await chromeScript.promiseOneMessage("done");
ok(consoleShown, "console was shown");
chromeScript.destroy();
await extension.unload();
});
</script>
await extension.unload();
});
</script>
</body>
</body>
</html>

View File

@ -174,10 +174,7 @@ const FEATURES = [
"urlclassifier.features.fingerprinting.annotate.whitelistTables",
],
enabled() {
return Services.prefs.getBoolPref(
"privacy.trackingprotection.fingerprinting.annotate.enabled",
false
);
return true;
},
update() {
return Services.prefs.getBoolPref(
@ -250,10 +247,7 @@ const FEATURES = [
"urlclassifier.features.socialtracking.annotate.whitelistTables",
],
enabled() {
return Services.prefs.getBoolPref(
"privacy.trackingprotection.socialtracking.annotate.enabled",
false
);
return true;
},
update() {
return Services.prefs.getBoolPref(

View File

@ -14,10 +14,14 @@ runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_TRACKING,
[
["privacy.trackingprotection.enabled", true],
["privacy.trackingprotection.annotate_channels", true],
["privacy.trackingprotection.fingerprinting.annotate.enabled", false],
["urlclassifier.features.fingerprinting.annotate.blacklistTables", ""],
["urlclassifier.features.fingerprinting.annotate.blacklistHosts", ""],
["privacy.trackingprotection.fingerprinting.enabled", false],
["privacy.trackingprotection.cryptomining.annotate.enabled", false],
["urlclassifier.features.cryptomining.annotate.blacklistTables", ""],
["urlclassifier.features.cryptomining.annotate.blacklistHosts", ""],
["privacy.trackingprotection.cryptomining.enabled", false],
["urlclassifier.features.socialtracking.annotate.blacklistTables", ""],
["urlclassifier.features.socialtracking.annotate.blacklistHosts", ""],
],
true /* a tracking resource */);
SimpleTest.waitForExplicitFinish();

View File

@ -14,11 +14,12 @@ runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_CRYPTOMINING,
[
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.fingerprinting.annotate.enabled", false],
["urlclassifier.features.fingerprinting.annotate.blacklistHosts", ""],
["urlclassifier.features.fingerprinting.annotate.blacklistTables", ""],
["privacy.trackingprotection.fingerprinting.enabled", false],
["privacy.trackingprotection.cryptomining.annotate.enabled", true],
["privacy.trackingprotection.cryptomining.enabled", true],
["privacy.trackingprotection.socialtracking.annotate.enabled", false],
["urlclassifier.features.socialtracking.annotate.blacklistHosts", ""],
["urlclassifier.features.socialtracking.annotate.blacklistTables", ""],
["privacy.trackingprotection.socialtracking.enabled", false],
],
false /* a tracking resource */);

View File

@ -14,11 +14,12 @@ runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_FINGERPRINTING,
[
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.fingerprinting.annotate.enabled", true],
["privacy.trackingprotection.fingerprinting.enabled", true],
["privacy.trackingprotection.cryptomining.annotate.enabled", false],
["urlclassifier.features.cryptomining.annotate.blacklistHosts", ""],
["urlclassifier.features.cryptomining.annotate.blacklistTables", ""],
["privacy.trackingprotection.cryptomining.enabled", false],
["privacy.trackingprotection.socialtracking.annotate.enabled", false],
["urlclassifier.features.socialtracking.annotate.blacklistHosts", ""],
["urlclassifier.features.socialtracking.annotate.blacklistTables", ""],
["privacy.trackingprotection.socialtracking.enabled", false],
],
true /* a tracking resource */);

View File

@ -14,11 +14,12 @@ runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_SOCIALTRACKING,
[
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.annotate_channels", false],
["privacy.trackingprotection.fingerprinting.annotate.enabled", false],
["urlclassifier.features.fingerprinting.annotate.blacklistHosts", ""],
["urlclassifier.features.fingerprinting.annotate.blacklistTables", ""],
["privacy.trackingprotection.fingerprinting.enabled", false],
["privacy.trackingprotection.cryptomining.annotate.enabled", false],
["urlclassifier.features.cryptomining.annotate.blacklistHosts", ""],
["urlclassifier.features.cryptomining.annotate.blacklistTables", ""],
["privacy.trackingprotection.cryptomining.enabled", false],
["privacy.trackingprotection.socialtracking.annotate.enabled", true],
["privacy.trackingprotection.socialtracking.enabled", true],
],
false /* a tracking resource */);