Skip to content

Commit

Permalink
Fix CTL messaging in the MV2 extension (#1378)
Browse files Browse the repository at this point in the history
* Fix CTL messaging in the MV2 extension

* Remove CTL from the Android build
  • Loading branch information
muodov authored Jan 9, 2025
1 parent ac20cef commit b2b227e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions injected/entry-points/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ function init() {
return console.warn('no details in sendMessage proxy', event);
}

const messageType = event.detail?.messageType;
const eventDetail = JSON.parse(event.detail);
const messageType = eventDetail.messageType;
if (!allowedMessages.includes(messageType)) {
return console.warn('Ignoring invalid sendMessage messageType', messageType);
}

chrome.runtime.sendMessage(event.detail, (response) => {
chrome.runtime.sendMessage(eventDetail, (response) => {
const message = {
messageType: 'response',
responseMessageType: messageType,
Expand Down
2 changes: 1 addition & 1 deletion injected/src/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const otherFeatures = /** @type {const} */ ([
export const platformSupport = {
apple: ['webCompat', ...baseFeatures],
'apple-isolated': ['duckPlayer', 'brokerProtection', 'performanceMetrics', 'clickToLoad', 'messageBridge'],
android: [...baseFeatures, 'webCompat', 'clickToLoad', 'breakageReporting', 'duckPlayer'],
android: [...baseFeatures, 'webCompat', 'breakageReporting', 'duckPlayer'],
'android-autofill-password-import': ['autofillPasswordImport'],
windows: ['cookie', ...baseFeatures, 'windowsPermissionUsage', 'duckPlayer', 'brokerProtection', 'breakageReporting'],
firefox: ['cookie', ...baseFeatures, 'clickToLoad'],
Expand Down
3 changes: 2 additions & 1 deletion injected/src/features/click-to-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ export default class ClickToLoad extends ContentFeature {
get messaging() {
if (this._messaging) return this._messaging;

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

0 comments on commit b2b227e

Please sign in to comment.