Uncaught SecurityError when using iframe
When using videoJS inside an iframe, the following code runs and cause an exception:
var hasAutomationEqualityBug = (function () {
/* global window */
if (typeof window === 'undefined') { return false; }
for (var k in window) {
if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
equalsConstructorPrototype(window[k]);
} catch (e) {
return true;
}
}
}
return false;
}());
The problem is that window.frameElement throwing the following example:
Uncaught SecurityError: Failed to read the 'frame' property from 'Window': Blocked a frame with origin "https://frontend.dev:8001" from accessing a frame with origin "http://frontend.dev:8000". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
I have the same problem. Confirmed.
So the code snippet you're referencing comes from the ES5-shim, but is this really a VJS issue? Trying to access an HTTPS-origin frame from an HTTP-origin frame isn't ever going to work for obvious security reasons. Mind putting up an example?
Sounds like frame is another key that es5-shim might need to add to the blacklistedKeys array. See https://github.com/es-shims/es5-shim/issues/322 for reference.
@mmcc in my case, the issue is occurring with an https iframe inside a cross-origin, https page. Of course we shouldn't expect it to work, but it's still a bug that is effectively breaking my iframe's JS behavior due to the generated SecurityError.
What version of videojs are you using? 5.0? Are you using our ie8 shim?
* Video.js 5.0.0 <http://videojs.com/>
I don't believe I'm using any IE8 shim. Not sure how to confirm that.
This SecurityError is with latest stable Google Chrome, BTW.
@jtwalters do you have an example?
I put together this jsfiddle which will give you a SecurityError viewable in the console.
Of course this is an oversimplified example and doesn't actually represent the error that I have.
Ah, I think i see where it's coming from. This is from our object.assign module which uses an older version of object-keys which has a newer version which has frameElement blacklisted.
Do you want to put together a PR that updates object.assign to the latest version?
I am using videoJS with npm and require it like this:
var videojs = require(video.js);
I didn't ask to include es5 shim.
Whenever videojs is inside an iframe, I get this error.
Any solution?
Yes, me too, same problem. Videojs 5.0.0 produces the security error in Google Chrome, but the security error stops videojs from loading inside an iFrame. A quick fix would be HUGELY appreciated!
Same issue, only in the latest chrome (v 46)
If anyone needs a quick fix in the meantime, modifying this in your own hosted copy of Video.js works for me in Chrome 46:
var hasAutomationEqualityBug = (function () {
...
for (var k in window) {
if (k === 'frameElement') {
continue;
}
...
}
}());
@rickyblaha I am using the CDN version of videojs and the quick fix doesn't fix that issue. Did you manually change the video.js file?
@jemoreno, just edited my comment to clarify. Since that is immediately invoked it would need to be changed within the library, so I did make that change on my own CDN-hosted copy.
Working on getting this fixed.
Waiting on https://github.com/ljharb/object-keys/pull/17
Also note that the latest versions of es5-shim and object-keys have the blacklisting wrapped with a try/catch, so this should already be "fixed" in the latest version.
That said, thanks for the "frame" PR, as I'd still like to blacklist all throwing keys that I can :-)