Skip to content

Commit

Permalink
browser(firefox-stable): roll Firefox to 104.0
Browse files Browse the repository at this point in the history
References microsoft#16780
  • Loading branch information
aslushnikov committed Aug 23, 2022
1 parent ad46e98 commit 8772296
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 253 deletions.
4 changes: 2 additions & 2 deletions browser_patches/firefox/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1346
Changed: yurys@chromium.org Mon Aug 22 16:56:24 PDT 2022
1347
Changed: lushnikov@chromium.org Tue 23 Aug 2022 03:05:32 PM PDT
2 changes: 1 addition & 1 deletion browser_patches/firefox/UPSTREAM_CONFIG.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REMOTE_URL="https://github.com/mozilla/gecko-dev"
BASE_BRANCH="release"
BASE_REVISION="f532fa26bc150add9f8ba42e5fbfdbeffa23662f"
BASE_REVISION="fd854580ffc6fba6a0acdf335c96a1b24b976cb9"
135 changes: 135 additions & 0 deletions browser_patches/firefox/juggler/components/Juggler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var EXPORTED_SYMBOLS = ["Juggler", "JugglerFactory"];

const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {ComponentUtils} = ChromeUtils.import("resource://gre/modules/ComponentUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const {Dispatcher} = ChromeUtils.import("chrome://juggler/content/protocol/Dispatcher.js");
const {BrowserHandler} = ChromeUtils.import("chrome://juggler/content/protocol/BrowserHandler.js");
const {NetworkObserver} = ChromeUtils.import("chrome://juggler/content/NetworkObserver.js");
const {TargetRegistry} = ChromeUtils.import("chrome://juggler/content/TargetRegistry.js");
const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
const helper = new Helper();

const Cc = Components.classes;
const Ci = Components.interfaces;

const FRAME_SCRIPT = "chrome://juggler/content/content/main.js";

let browserStartupFinishedCallback;
let browserStartupFinishedPromise = new Promise(x => browserStartupFinishedCallback = x);

class Juggler {
get classDescription() { return "Sample command-line handler"; }
get classID() { return Components.ID('{f7a74a33-e2ab-422d-b022-4fb213dd2639}'); }
get contractID() { return "@mozilla.org/remote/juggler;1" }
get QueryInterface() {
return ChromeUtils.generateQI([ Ci.nsICommandLineHandler, Ci.nsIObserver ]);
}
get helpInfo() {
return " --juggler Enable Juggler automation\n";
}

handle(cmdLine) {
// flag has to be consumed in nsICommandLineHandler:handle
// to avoid issues on macos. See Marionette.jsm::handle() for more details.
// TODO: remove after Bug 1724251 is fixed.
cmdLine.handleFlag("juggler-pipe", false);
}

// This flow is taken from Remote agent and Marionette.
// See https://github.com/mozilla/gecko-dev/blob/0c1b4921830e6af8bc951da01d7772de2fe60a08/remote/components/RemoteAgent.jsm#L302
async observe(subject, topic) {
switch (topic) {
case "profile-after-change":
Services.obs.addObserver(this, "command-line-startup");
Services.obs.addObserver(this, "browser-idle-startup-tasks-finished");
break;
case "command-line-startup":
Services.obs.removeObserver(this, topic);
const cmdLine = subject;
const jugglerPipeFlag = cmdLine.handleFlag('juggler-pipe', false);
if (!jugglerPipeFlag)
return;

this._silent = cmdLine.findFlag('silent', false) >= 0;
if (this._silent) {
Services.startup.enterLastWindowClosingSurvivalArea();
browserStartupFinishedCallback();
}
Services.obs.addObserver(this, "final-ui-startup");
break;
case "browser-idle-startup-tasks-finished":
browserStartupFinishedCallback();
break;
// Used to wait until the initial application window has been opened.
case "final-ui-startup":
Services.obs.removeObserver(this, topic);

const targetRegistry = new TargetRegistry();
new NetworkObserver(targetRegistry);

const loadFrameScript = () => {
Services.mm.loadFrameScript(FRAME_SCRIPT, true /* aAllowDelayedLoad */);
if (Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo).isHeadless) {
const styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
const uri = ioService.newURI('chrome://juggler/content/content/hidden-scrollbars.css', null, null);
styleSheetService.loadAndRegisterSheet(uri, styleSheetService.AGENT_SHEET);
}
};

// Force create hidden window here, otherwise its creation later closes the web socket!
Services.appShell.hiddenDOMWindow;

let pipeStopped = false;
let browserHandler;
const pipe = Cc['@mozilla.org/juggler/remotedebuggingpipe;1'].getService(Ci.nsIRemoteDebuggingPipe);
const connection = {
QueryInterface: ChromeUtils.generateQI([Ci.nsIRemoteDebuggingPipeClient]),
receiveMessage(message) {
if (this.onmessage)
this.onmessage({ data: message });
},
disconnected() {
if (browserHandler)
browserHandler['Browser.close']();
},
send(message) {
if (pipeStopped) {
// We are missing the response to Browser.close,
// but everything works fine. Once we actually need it,
// we have to stop the pipe after the response is sent.
return;
}
pipe.sendMessage(message);
},
};
pipe.init(connection);
const dispatcher = new Dispatcher(connection);
browserHandler = new BrowserHandler(dispatcher.rootSession(), dispatcher, targetRegistry, () => {
if (this._silent)
Services.startup.exitLastWindowClosingSurvivalArea();
connection.onclose();
pipe.stop();
pipeStopped = true;
}, () => browserStartupFinishedPromise);
dispatcher.rootSession().setHandler(browserHandler);
loadFrameScript();
dump(`\nJuggler listening to the pipe\n`);
break;
}
}

}

const jugglerInstance = new Juggler();

// This is used by the XPCOM codepath which expects a constructor
var JugglerFactory = function() {
return jugglerInstance;
};

18 changes: 18 additions & 0 deletions browser_patches/firefox/juggler/components/components.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Classes = [
# Juggler
{
"cid": "{f7a74a33-e2ab-422d-b022-4fb213dd2639}",
"contract_ids": ["@mozilla.org/remote/juggler;1"],
"categories": {
"command-line-handler": "m-remote",
"profile-after-change": "Juggler",
},
"jsm": "chrome://juggler/content/components/Juggler.js",
"constructor": "JugglerFactory",
},
]

131 changes: 0 additions & 131 deletions browser_patches/firefox/juggler/components/juggler.js

This file was deleted.

3 changes: 0 additions & 3 deletions browser_patches/firefox/juggler/components/juggler.manifest

This file was deleted.

5 changes: 1 addition & 4 deletions browser_patches/firefox/juggler/components/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

EXTRA_COMPONENTS += [
"juggler.js",
"juggler.manifest",
]
XPCOM_MANIFESTS += ["components.conf"]

4 changes: 2 additions & 2 deletions browser_patches/firefox/juggler/content/PageAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ class PageAgent {
false /*aIgnoreRootScrollFrame*/,
undefined /*pressure*/,
undefined /*inputSource*/,
undefined /*isDOMEventSynthesized*/,
undefined /*isWidgetEventSynthesized*/,
true /*isDOMEventSynthesized*/,
false /*isWidgetEventSynthesized*/,
buttons);
obs.removeObserver(trapDrag, 'on-datatransfer-available');

Expand Down
3 changes: 3 additions & 0 deletions browser_patches/firefox/juggler/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

juggler.jar:
% content juggler %content/

content/components/Juggler.js (components/Juggler.js)

content/Helper.js (Helper.js)
content/NetworkObserver.js (NetworkObserver.js)
content/TargetRegistry.js (TargetRegistry.js)
Expand Down
4 changes: 3 additions & 1 deletion browser_patches/firefox/juggler/protocol/BrowserHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.j
const helper = new Helper();

class BrowserHandler {
constructor(session, dispatcher, targetRegistry, onclose) {
constructor(session, dispatcher, targetRegistry, onclose, onstart) {
this._session = session;
this._dispatcher = dispatcher;
this._targetRegistry = targetRegistry;
Expand All @@ -24,11 +24,13 @@ class BrowserHandler {
this._createdBrowserContextIds = new Set();
this._attachedSessions = new Map();
this._onclose = onclose;
this._onstart = onstart;
}

async ['Browser.enable']({attachToDefaultContext}) {
if (this._enabled)
return;
await this._onstart();
this._enabled = true;
this._attachToDefaultContext = attachToDefaultContext;

Expand Down
Loading

0 comments on commit 8772296

Please sign in to comment.