Skip to content

Commit d2a6174

Browse files
authored
chore: update browser_patches to 7eee05d75 (#37688)
1 parent 288bd87 commit d2a6174

File tree

10 files changed

+1157
-1519
lines changed

10 files changed

+1157
-1519
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REMOTE_URL="https://github.com/mozilla-firefox/firefox"
22
BASE_BRANCH="release"
3-
BASE_REVISION="361373160356d92cb5cd4d67783a3806c776ee78"
3+
BASE_REVISION="c1ee0105d25a4c2b2887e916470bdf41a9fd47ef"
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { ComponentUtils } from "resource://gre/modules/ComponentUtils.sys.mjs";
6+
7+
const Cm = Components.manager;
8+
9+
/**
10+
* This is a nsIChannelEventSink implementation that monitors channel redirects.
11+
* This has been forked from:
12+
* https://searchfox.org/mozilla-central/source/devtools/server/actors/network-monitor/channel-event-sink.js
13+
* The rest of this module is also more or less forking:
14+
* https://searchfox.org/mozilla-central/source/devtools/server/actors/network-monitor/network-observer.js
15+
* TODO(try to re-unify /remote/ with /devtools code)
16+
*/
17+
const SINK_CLASS_DESCRIPTION = "NetworkMonitor Channel Event Sink";
18+
const SINK_CLASS_ID = Components.ID("{c2b4c83e-607a-405a-beab-0ef5dbfb7617}");
19+
const SINK_CONTRACT_ID = "@mozilla.org/network/monitor/channeleventsink;1";
20+
const SINK_CATEGORY_NAME = "net-channel-event-sinks";
21+
22+
function ChannelEventSink() {
23+
this.wrappedJSObject = this;
24+
this.collectors = new Set();
25+
}
26+
27+
ChannelEventSink.prototype = {
28+
QueryInterface: ChromeUtils.generateQI(["nsIChannelEventSink"]),
29+
30+
registerCollector(collector) {
31+
this.collectors.add(collector);
32+
},
33+
34+
unregisterCollector(collector) {
35+
this.collectors.delete(collector);
36+
37+
if (this.collectors.size == 0) {
38+
ChannelEventSinkFactory.unregister();
39+
}
40+
},
41+
42+
asyncOnChannelRedirect(oldChannel, newChannel, flags, callback) {
43+
for (const collector of this.collectors) {
44+
try {
45+
collector._onChannelRedirect(oldChannel, newChannel, flags);
46+
} catch (ex) {
47+
console.error(
48+
"StackTraceCollector.onChannelRedirect threw an exception",
49+
ex
50+
);
51+
}
52+
}
53+
callback.onRedirectVerifyCallback(Cr.NS_OK);
54+
},
55+
};
56+
57+
export const ChannelEventSinkFactory =
58+
ComponentUtils.generateSingletonFactory(ChannelEventSink);
59+
60+
ChannelEventSinkFactory.register = function () {
61+
const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
62+
if (registrar.isCIDRegistered(SINK_CLASS_ID)) {
63+
return;
64+
}
65+
66+
registrar.registerFactory(
67+
SINK_CLASS_ID,
68+
SINK_CLASS_DESCRIPTION,
69+
SINK_CONTRACT_ID,
70+
ChannelEventSinkFactory
71+
);
72+
73+
Services.catMan.addCategoryEntry(
74+
SINK_CATEGORY_NAME,
75+
SINK_CONTRACT_ID,
76+
SINK_CONTRACT_ID,
77+
false,
78+
true
79+
);
80+
};
81+
82+
ChannelEventSinkFactory.unregister = function () {
83+
const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
84+
registrar.unregisterFactory(SINK_CLASS_ID, ChannelEventSinkFactory);
85+
86+
Services.catMan.deleteCategoryEntry(
87+
SINK_CATEGORY_NAME,
88+
SINK_CONTRACT_ID,
89+
false
90+
);
91+
};
92+
93+
ChannelEventSinkFactory.getService = function () {
94+
// Make sure the ChannelEventSink service is registered before accessing it
95+
ChannelEventSinkFactory.register();
96+
97+
return Cc[SINK_CONTRACT_ID].getService(Ci.nsIChannelEventSink)
98+
.wrappedJSObject;
99+
};

browser_patches/firefox/juggler/NetworkObserver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const {Helper} = ChromeUtils.importESModule('chrome://juggler/content/Helper.js');
88
const {NetUtil} = ChromeUtils.importESModule('resource://gre/modules/NetUtil.sys.mjs');
9-
const { ChannelEventSinkFactory } = ChromeUtils.importESModule("chrome://remote/content/cdp/observers/ChannelEventSink.sys.mjs");
9+
const { ChannelEventSinkFactory } = ChromeUtils.importESModule("chrome://juggler/content/ChannelEventSink.sys.mjs");
1010

1111

1212
const Cc = Components.classes;

browser_patches/firefox/juggler/TargetRegistry.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Cr = Components.results;
1313
const helper = new Helper();
1414

1515
const IDENTITY_NAME = 'JUGGLER ';
16-
const HUNDRED_YEARS = 60 * 60 * 24 * 365 * 100;
16+
const HUNDRED_YEARS = 1000 * 60 * 60 * 24 * 365 * 100;
1717

1818
const ALL_PERMISSIONS = [
1919
'geo',
@@ -1124,7 +1124,8 @@ class BrowserContext {
11241124

11251125
setCookies(cookies) {
11261126
const protocolToSameSite = {
1127-
[undefined]: Ci.nsICookie.SAMESITE_NONE,
1127+
[undefined]: Ci.nsICookie.SAMESITE_UNSET,
1128+
'None': Ci.nsICookie.SAMESITE_UNSET,
11281129
'Lax': Ci.nsICookie.SAMESITE_LAX,
11291130
'Strict': Ci.nsICookie.SAMESITE_STRICT,
11301131
};

browser_patches/firefox/juggler/jar.mn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ juggler.jar:
99

1010
content/Helper.js (Helper.js)
1111
content/NetworkObserver.js (NetworkObserver.js)
12+
content/ChannelEventSink.sys.mjs (ChannelEventSink.sys.mjs)
1213
content/TargetRegistry.js (TargetRegistry.js)
1314
content/SimpleChannel.js (SimpleChannel.js)
1415
content/JugglerFrameParent.jsm (JugglerFrameParent.jsm)

0 commit comments

Comments
 (0)