Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Feature request: Allow users to specify which URLs to sync against #3858

Open
@sjelin

Description

@sjelin

(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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions