Skip to content

Commit b2b227e

Browse files
authored
Fix CTL messaging in the MV2 extension (#1378)
* Fix CTL messaging in the MV2 extension * Remove CTL from the Android build
1 parent ac20cef commit b2b227e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

injected/entry-points/chrome.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ function init() {
146146
return console.warn('no details in sendMessage proxy', event);
147147
}
148148

149-
const messageType = event.detail?.messageType;
149+
const eventDetail = JSON.parse(event.detail);
150+
const messageType = eventDetail.messageType;
150151
if (!allowedMessages.includes(messageType)) {
151152
return console.warn('Ignoring invalid sendMessage messageType', messageType);
152153
}
153154

154-
chrome.runtime.sendMessage(event.detail, (response) => {
155+
chrome.runtime.sendMessage(eventDetail, (response) => {
155156
const message = {
156157
messageType: 'response',
157158
responseMessageType: messageType,

injected/src/features.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const otherFeatures = /** @type {const} */ ([
3333
export const platformSupport = {
3434
apple: ['webCompat', ...baseFeatures],
3535
'apple-isolated': ['duckPlayer', 'brokerProtection', 'performanceMetrics', 'clickToLoad', 'messageBridge'],
36-
android: [...baseFeatures, 'webCompat', 'clickToLoad', 'breakageReporting', 'duckPlayer'],
36+
android: [...baseFeatures, 'webCompat', 'breakageReporting', 'duckPlayer'],
3737
'android-autofill-password-import': ['autofillPasswordImport'],
3838
windows: ['cookie', ...baseFeatures, 'windowsPermissionUsage', 'duckPlayer', 'brokerProtection', 'breakageReporting'],
3939
firefox: ['cookie', ...baseFeatures, 'clickToLoad'],

injected/src/features/click-to-load.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ export default class ClickToLoad extends ContentFeature {
19911991
get messaging() {
19921992
if (this._messaging) return this._messaging;
19931993

1994-
if (this.platform.name === 'android' || this.platform.name === 'extension') {
1994+
if (this.platform.name === 'extension') {
19951995
this._clickToLoadMessagingTransport = new SendMessageMessagingTransport();
19961996
const config = new TestTransportConfig(this._clickToLoadMessagingTransport);
19971997
this._messaging = new Messaging(this.messagingContext, config);
@@ -2005,6 +2005,7 @@ export default class ClickToLoad extends ContentFeature {
20052005
this._messaging = new Messaging(this.messagingContext, config);
20062006
return this._messaging;
20072007
} else {
2008+
// TODO: Android does support Messaging now, but CTL is not yet integrated there.
20082009
throw new Error('Messaging not supported yet on platform: ' + this.name);
20092010
}
20102011
}

0 commit comments

Comments
 (0)