-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Catch cross-origin DOMException #861
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
Conversation
@@ -10,8 +10,16 @@ const GumgumAdapter = function GumgumAdapter() { | |||
|
|||
const bidEndpoint = `https://g2.gumgum.com/hbid/imp`; | |||
|
|||
const WINDOW = global.top; | |||
const SCREEN = WINDOW.screen; | |||
let WINDOW; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why caps? Probably should make this more consistent with our style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep a clear reference to the variable in a local scope. But I'm open to suggestions. What would be the Prebid approach to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well we normally reserve caps for constants, anything else should just be camelCase. Also as an FYI we have some helper functions that safely attempt tot access window.top.* variables that might be helpful: https://github.com/prebid/Prebid.js/blob/master/src/utils.js#L193
SCREEN = WINDOW.screen; | ||
} catch (error) { | ||
utils.logError(error); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the adapter require access to window.top
or can it continue if it fails to get access? Maybe a question for @davidmh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need to access window.top
, since the service was built with the idea of having the top being the host of the script.
Especially with the In-Screen service which uses the placement a 1x1 pixel, because our In-Screen uses fluid designs across the window width. If we do not have access to top
, the In-Screen should not run.
@mkendall07 I can work on this if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidmh
We'd like to merge this code for now to fix our jsfiddle examples for the 0.16.x release. (see here http://jsfiddle.net/prebid/bhn3xk2j/4/? for example).
Basically, because JsFiddle sandboxes the execution environment, access to window.top is blocked. Typically on a publisher page this is not the case but it causes our examples to stop working. The above code catches this error and will not run GumGum adapter in that case.
Feel free to work on a solution that would support an sandboxed environment though for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll work on my proposal on top of your changes.
Thank you @mkendall07
Confirmed this resolves the cross-orgin error and ads are loading on JsFiddle pages again. Thanks |
…ebid-official-0.16.0 to release/1.10.0 * commit 'fd16420d7034b1f82e571e2b122b7fa73b88d929': Add changelog entry. Add new adapters for AOL analytics. Updated Prebid version Catch cross-origin DOMException (prebid#861) Add GumGum adapter (prebid#833) Remove duplicate log line in request bids (prebid#859) Utility function getBidIdParamater is misspelled Allow Conversant sizes to be overridden per placement (prebid#816) Add districtmDMX adapter (prebid#811) Truncate bids requested on clearPlacements (prebid#825) (prebid#828) Update adapters.json (prebid#803) Add usersyncing to AppNexus adapters (prebid#845) fixes for bugs in test suite (prebid#810) Pass user object parameters on bid request (prebid#821) fix rubicon deals to be per ad instead of per response (prebid#838) Links bidId in request with adId in response for analytics purposes (prebid#836) Bugfix/issue building from npm (prebid#823) Update build to only run `webpack` to improve build time performance (prebid#809) Cast all Conversant site_ids to a string (prebid#829) Increment pre version
…10.0 to master * commit 'b39f2b12a8ddfa650a8e04e3abd358e60371950a': Add changelog entry. Add new adapters for AOL analytics. Updated Prebid version Catch cross-origin DOMException (prebid#861) Add GumGum adapter (prebid#833) Remove duplicate log line in request bids (prebid#859) Utility function getBidIdParamater is misspelled Allow Conversant sizes to be overridden per placement (prebid#816) Add districtmDMX adapter (prebid#811) Truncate bids requested on clearPlacements (prebid#825) (prebid#828) Update adapters.json (prebid#803) Add usersyncing to AppNexus adapters (prebid#845) fixes for bugs in test suite (prebid#810) Pass user object parameters on bid request (prebid#821) fix rubicon deals to be per ad instead of per response (prebid#838) Links bidId in request with adId in response for analytics purposes (prebid#836) Bugfix/issue building from npm (prebid#823) Update build to only run `webpack` to improve build time performance (prebid#809) Cast all Conversant site_ids to a string (prebid#829) Increment pre version
Type of change
Description of change
Accessing
global.top
from the GumGum adapter is causingUncaught DOMException: Blocked a frame with origin "<url>" from accessing a cross-origin frame.
in setups such as the prebid.org example pages. This change catches that exception.Other information
cc @davidmh