forked from bluesmoon/boomerang
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make self url detection work when loaded in primary window as well
Our self-url (`BOOMR.url`) detection logic only worked when we loaded in an iframe because the logic checks for `w.parent !== w`. This fails if boomerang is loaded in the primary window (eg using a static script or async loader or link rel="preload"). This patch fixes this logic: 1. Move the self-url detection logic out of the `if (w.parent !== w)` block 2. Use `document.currentScript` to check for self url, which should work for all browsers except IE even if we don't have an `id` set on the script 3. Use `document.getElementById("boomr-scr-as")` as well, which our new preloader loader will use to load boomerang into the primary window. As a side-effect, boomerang will now correctly detect its API KEY even if loaded in a non-standard manner (except for IE) as we use `document.currentScript`. Additionally, the following bugs in unit tests were fixed: - Restiming tests that did not exclude boomerang & config urls from the check. This worked in the past because when loading boomerang in the parent window, our self-url check failed, so we weren't excluding boomerang from the RT trie. After fixing the above, these tests started failing since we were now doing the right thing. The tests have now been fixed to also do the right thing. - BOOMR_mq tests that were not using `BOOMR.window.` to dereference `BOOMR_mq` It is not clear why these tests failed without `BOOMR.window`, this also only appears to happen on headless chrome, which runs the tests on jenkins.
- Loading branch information
Showing
4 changed files
with
17 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters