Feature request: Allow users to specify which URLs to sync against #3858
Description
(edited based on the discussion below)
Instead of forcing users to manage browser.ignoreSynchronization
, we could allow users to tell us which URLs point to apps which need to be synced, and which do not. Probably, a good API would be:
type syncCondition: boolean | string | string[] | {[url: string]: boolean} | RegExp | RegExp[] | (url: string) => boolean;
config.synchronizeWhen: syncCondition;
config.disableSynchronizeWhen: syncCondition;
browser.setSynchronizeWhen: (synchronizeWhen: syncCondition | wdpromise.Promise<syncCondition>) => wdpromise.Promise<syncCondition>; // Returns old `synchronizeWhen`
browser.setDisableSynchronizeWhen: (disableSynchronizeWhen: syncCondition | wdpromise.Promise<syncCondition>) => wdpromise.Promise<syncCondition>; // Returns old `disableSynchronizeWhen`
/**
* We will synchronize on a page if its url passes `synchronizeWhen` but not
* `disableSynchronizeWhen`. `synchronizeWhen` defaults to `true` and
* `disableSynchronizeWhen defaults to `false`. Users can modify these at run time
* via the corresponding `browser` methods
*/
Users can use synchronizeWhen
to specify the base URL for their app, and disableSynchronizeWhen
to specify any sub pages which don't have angular. If there are special cases where they need finer control, they can do something like:
browser.setSynchronizeWhen(false).then((oldSyncWhen) =>
doSomeUnsynchedStuff();
return setSynchronizeWhen(oldSyncWhen);
});
Edge Case: Navigation without bootstrap
An issue with this idea is that if navigation happened via something other than browser.get
(e.g. someone clicks on a link), we wouldn't get to bootstrap and would end up using an outdated synchronization setting from a previous page. However, #3857 should address that.
Edge Case: Blocking Proxy
Blocking Proxy currently does not have the APIs needed to support this change. There is an issue to expand the APIs on the Blocking Proxy repo: angular/blocking-proxy#16