Use chrome.runtime.reload()

218 views
Skip to first unread message

Pavel Aronovich

unread,
Oct 19, 2023, 3:35:49 AM10/19/23
to Chromium Extensions
Hi,

In the usual extension installed from CWS (not unpacked), calling method chrome.runtime.reload() always leads to calling event (reason=='update'): chrome.runtime.onInstalled()?

Thanks.


Oliver Dunk

unread,
Oct 19, 2023, 4:29:36 AM10/19/23
to Pavel Aronovich, Chromium Extensions
Hi Pavel,

In an extension installed from the web store, I wouldn't expect this to fire. It only fires in unpacked extensions because reloads are treated slightly differently there and get considered as an update.

Do you see otherwise?
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
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/51bee999-cd89-4ed6-a365-3493d63b85b4n%40chromium.org.

Pavel Aronovich

unread,
Oct 19, 2023, 4:37:07 AM10/19/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, Pavel Aronovich
It looks like it is

четверг, 19 октября 2023 г. в 11:29:36 UTC+3, Oliver Dunk:

Oliver Dunk

unread,
Oct 19, 2023, 4:41:01 AM10/19/23
to Pavel Aronovich, Chromium Extensions
It looks like chrome.runtime.onInstalled is firing? Can you share how you're testing?
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Pavel Aronovich

unread,
Oct 19, 2023, 4:41:20 AM10/19/23
to Chromium Extensions, Pavel Aronovich, Oliver Dunk, Chromium Extensions
It would be good to reflect this in the documentation. In general, it is very bad that the behavior of the unpacked extension and the one installed from CWS is different. It is very difficult to develop and debug in this form. At least all this should be reflected in the documentation!

четверг, 19 октября 2023 г. в 11:37:07 UTC+3, Pavel Aronovich:

Pavel Aronovich

unread,
Oct 19, 2023, 4:44:00 AM10/19/23
to Chromium Extensions, Pavel Aronovich, Oliver Dunk, Chromium Extensions
 chrome.runtime.onInstalled is firing exactly in the unpacked extension

четверг, 19 октября 2023 г. в 11:41:20 UTC+3, Pavel Aronovich:

Pavel Aronovich

unread,
Oct 19, 2023, 4:55:26 AM10/19/23
to Chromium Extensions, Pavel Aronovich, Oliver Dunk, Chromium Extensions
"I wouldn't expect this to fire" - ie it's not accurate? :)

четверг, 19 октября 2023 г. в 11:44:00 UTC+3, Pavel Aronovich:

Oliver Dunk

unread,
Oct 19, 2023, 5:07:56 AM10/19/23
to Pavel Aronovich, Chromium Extensions
I definitely agree that this would be nice to document. I've opened a PR to add a note: https://github.com/GoogleChrome/developer.chrome.com/pull/7595

There are some cases where this can be useful for development - if you want to test your update logic, for example. You can use https://github.com/GoogleChromeLabs/extension-update-testing-tool if you want to more accurately simulate how extensions from the Chrome Web Store behave.

"I wouldn't expect this to fire" - ie it's not accurate? :)

Whenever an unpacked extension reloads, chrome.runtime.onInstalled should fire with the update reason. When an extension from the store is reloaded, it should only fire if the version changed.

Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Pavel Aronovich

unread,
Oct 19, 2023, 3:59:00 PM10/19/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, Pavel Aronovich
Oliver,

And if runtime.reload() is called in event onAvailableUpdate, then will the event onInstalled is called? 

четверг, 19 октября 2023 г. в 12:07:56 UTC+3, Oliver Dunk:

Oliver Dunk

unread,
Oct 20, 2023, 7:21:16 AM10/20/23
to Pavel Aronovich, Chromium Extensions
Yes, it should :)
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Reply all
Reply to author
Forward
0 new messages