Can you share detailed reproduction steps for you test procedure? I attempted to reproduce your results in Chrome stable channel version 146.0.7680.81 using the
Chrome extension source viewer extension, but failed. I chose this extension because it uses the CWS install flow and does not use storage.sync immediately after installation.
Here are my detailed reproduction steps:
1. Launch Chrome.
2. Ensure that you do not currently have any profiles logged into your test Google account.
3. In Chrome, click the Profile icon in the top right corner and select Add Chrome Profile.
4. In the profile creation wizard, select the "Stay signed out" option and name this profile "TEST-1".
5. In TEST-1, click the Profile icon in the top right corner and click "Sign in to Chrome" from the top of the menu.
6. Log into the test Google account.
7. Click the Profile icon again to verify that a "Turn on sync..." button appears at the top of the prompt.
8. Using the profile menu from the previous step, click Add Chrome Profile.
9. In the profile creation wizard, select the "Stay signed out" option and name this profile "TEST-2".
10. In TEST-2, click the Profile icon in the top right corner and click "Sign in to Chrome" from the top of the menu.
11. Log into the test Google account.
12. Click the Profile icon again and click the "Turn on sync..." button at the top of the menu.
13. Open chrome://settings/syncSetup to verify that sync is enabled.
14. Open chrome://settings/syncSetup/advanced and verify that either Sync Everything is enabled or that Customize Sync is enabled and the Extension sub-control is also enabled.
15. In TEST-1, visit
https://chromewebstore.google.com/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin in a new tab and install the extension.
16. While viewing the CWS listing, expand the Extensions menu and click the Chrome extension source viewer entry. This will open an extension page in a new tab.
17. While viewing the Chrome extension source viewer page, right click the page and select Inspect.
18. In the DevTools console, execute the following command: await chrome.storage.sync.get(null).
19. Observe that this storage area contains no data.
20. In the DevTools console, execute the following command: await chrome.storage.sync.set({a: 'alpha'}).
21. Repeat step 18 and observe that the value set in step 20 is present.
22. In TEST-2, repeat steps 15-19.
23. In the DevTools console for TEST-2, execute the following command: await chrome.storage.sync.set({b: 'beta'}).
24. Repeat step 18 and observe that that the value set in step 23 is present while the value set in step 20 is not.
25. In the DevTools console for TEST-1, repeat step 18 and observe that the result is identical to the one returned in step 21.
Note that I was not able to test having two profiles logged into the same Google Account at the same time because when I attempted to do so, I encountered the following message:
Can't sign in to <email address>
This account is already being used on this computer by <Name> (<Profile>).
Regarding your specific questions, I should note that I'm not a Googler and am not deeply familiar with Chrome's sync system.
1. I would not expect the behavior you've described. More specifically, I would expect that if I log into a Google account in Chrome and disabled sync entirely or disabled the extension sync setting on the chrome://settings/syncSetup page, data written to storage.sync in extensions would stop syncing.
2. Based on your testing, it seems clear that the handling of chrome.storage.sync is not exclusively governed "by the Chrome sync toggle" or "by whether the user is signed into their Google account". I tried to do some digging in Chromium source, but the more I dug the more complicated the situation became.
As far as I can tell, Chromium is currently in the middle of a transition between a Chrome profile-based sync feature to a Google-account based system where sync is used as an underlying transport for the account settings. See the comment above
the SyncService class for a breakdown of the distinction between sync-the-feature and sync-the-transport. The
CanUploadAsAccountExtension function in account_extension_tracker.cc also has some illustrative comments; that's where I first encountered the term "account extension," which seems to be an extension associated with the logged-in user account rather than the synced profile.
3. To my knowledge there is no method or property that indicates whether Sync is active. The closest thing you can do is observe a storage.onChanged event for the "sync" area that you did not initiate locally. This would allow you to infer that the change came from installation of the same extension.