Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove location.search calls from SMP plugin #730

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

andy-brown
Copy link
Contributor

Details

Prevents SMP plugin from throwing a console error in Chrome, since window.location cannot be used within iframe.

I've only been able to test that the noUi=true query parameter still works, as I can't bring up a local SPH instance with a local SP linked.

Ticket / issue URL

Ticket / issue URL: https://jira.dev.bbc.co.uk/browse/PRODTOOLS-3980

PR Checks

(tick as appropriate)

@andy-brown andy-brown changed the title 3980 remove location search fix: remove location.search calls from SMP plugin Feb 5, 2024
new URLSearchParams(parent.location.search).getAll("noUi")
.length > 0 || this._controller.options?.noUi
const useExternal =
getSetting("noUi") === "true" || this._controller.options?.noUi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the storyplayer harness plugin (https://github.com/bbc/rd-ux-storyplayer-harness/blob/0fba3592def9540b835efe2ef0a2535af9f40b0f/plugin/plugin.js#L31C1-L31C84), to get the URL of the enclosing page we use:
const pageUrl = new URL(pluginUtils.playerInterface.settings.embedPageURL);

Not sure if that makes any difference to how we do things

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this is meaningless outside the plugin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah of course

Copy link
Contributor

@craigjohnwright craigjohnwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally managed to get this tested. Tested using the SMP Plugin in the Harness with Storyplayer version 1.4.4 (main) and 1.4.5 (this PR) to play Click100.

Repeated the error in Chrome on 1.4.4:
DOMException: Failed to read a named property 'search' from 'Location': Blocked a frame with origin "https: //emp.bbcconne smp-js:71 ctedstudio.co.uk" from accessing a cross-origin frame.

No error in 1.4.5. Playback all seems correct.

@craigjohnwright craigjohnwright merged commit aed18cc into main Mar 11, 2024
2 checks passed
@craigjohnwright craigjohnwright deleted the 3980-remove-location-search branch March 11, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants