Cannot read properties of undefined (reading 'ime')

319 views
Skip to first unread message

Nathan Pierce

unread,
Oct 8, 2022, 10:29:11 AM10/8/22
to Chromium Extensions
Curious if someone can help me determine where I'm messing this up or what I'm missing:

Manifest:
{
"name": "Vertically Listed Tabs",
"description": "Manage your tabs vertically!",
"version": "0.3.0",
"manifest_version": 3,
"permissions": ["tabs","tabGroups","favicon","storage","system.display","input"],
"action": {
"default_title": "Open the VLT panel window."
},
"background": {
"service_worker": "background.js",
"type": "module"
},
"icons": {
"48": "img/vlticon-48x48.png",
"128": "img/vlticon-128x128.png"
},
"options_page": "options/options.html"
}

The background.js launches a window with an html and js file. In this window's js file, I use a bunch of addListeners for various things. In here, I have:

chrome.input.ime.onKeyEvent.addListener(
(engineID, keyData) => {
console.log(keyData)
}
)

Yet, I see Uncaught (in promise) TypeError:

"Cannot read properties of undefined (reading 'ime')"

According to https://developer.chrome.com/docs/extensions/reference/input_ime/#event-onKeyEvent, this should work.


What am I missing? Is it because this is only supported in the service_worker? IF so, that's insane since the worker is only alive for a few seconds. For context: I need to handle when the user executes (on macos) command + ~.
 

PhistucK

unread,
Oct 8, 2022, 12:26:07 PM10/8/22
to Nathan Pierce, Chromium Extensions
Just to verify - does the window you open have a chrome-extension:// URL?
I ask because I reckon it will not work in content scripts.

> that's insane since the worker is only alive for a few seconds
The service worker usually wakes up in response to events you listen to, so while that should not be a problem, I am guessing that the overhead of starting the service worker on key press might delay your response and cause a horrible user experience.

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/45bf07ab-4c5b-4d43-a4ed-fcf3538c325fn%40chromium.org.

Nathan Pierce

unread,
Oct 8, 2022, 12:38:53 PM10/8/22
to Chromium Extensions, PhistucK, Chromium Extensions, Nathan Pierce
Hey! Yep, it has chrome-extension://

I will test it in the service_worker and see what happens.

Jackie Han

unread,
Oct 8, 2022, 1:13:54 PM10/8/22
to Nathan Pierce, Chromium Extensions, PhistucK
input.ime api is only available on Chrome OS. As its name, this api is used to implement input method.

For context: I need to handle when the user executes (on macos) command + ~.
Cmd+` is a macOS system shortcut, you can't handle it. But you can use chrome.windows.onFocusChanged.addListener() to know when user focuses on another browser window.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages