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

"Access is denied" with iframes in IE #28

Open
tmsns opened this issue Jul 1, 2020 · 10 comments · May be fixed by #29
Open

"Access is denied" with iframes in IE #28

tmsns opened this issue Jul 1, 2020 · 10 comments · May be fixed by #29

Comments

@tmsns
Copy link

tmsns commented Jul 1, 2020

In IE, when iframes are being added to the page, the GOPN function throws with"Access is denied".

Screenshot

image

How to reproduce

  1. Go to https://jsbin.com/pafazegato/edit?html,output
    (I used a reference do a dummy doubleclick host, as my issue occurs when tags are being added to the page)
  2. Open up the preview in IE, and open up dev tools
  3. Make sure to refresh the page to see the "Access is denied" errors

Remarks

  • I suspect that this only happens when opening up the dev tools. As getOwnPropertyNames is being used by the dev tools themselves.
  • I'll send a PR later on today where I wrap the GOPN function (get-own-property-symbols.js#L125) with a try/catch.
@tmsns tmsns linked a pull request Jul 1, 2020 that will close this issue
@ljharb
Copy link
Member

ljharb commented Jul 1, 2020

I'm a bit unclear on this; where is Object.getOwnPropertyNames() being called, that it throws?

@tmsns
Copy link
Author

tmsns commented Jul 1, 2020

Well, to be honest, it's not 100% clear to me either.
As you can see, the code to reproduce the error is the polyfill and a simple iframe on the page. My theory is that the very fact of opening the devtools of IE, triggers the calls to Object.getOwnPropertyNames. When activating "breaking on uncaught errors", we can see that the object being passed is window, but more curiously the callstack only contains one frame, the call to it. I think the devtools calls Object.getOwnPropertyNames(window) to get data to be used in the devtools, not sure though.

@tmsns
Copy link
Author

tmsns commented Jul 1, 2020

You can actually see that devtools is triggering the throwing Object.getOwnPropertyNames(window) by adding some DOM manipulation in the catch clause.

@ljharb
Copy link
Member

ljharb commented Jul 1, 2020

Why would IE 11's devtools be calling a function that doesn't natively exist in IE 11?

@tmsns
Copy link
Author

tmsns commented Jul 1, 2020

Object.getOwnPropertyNames exists natively on IE11, it's Object.getOwnPropertySymbols that doesn't exist, right? 🙈
This polyfill overrides the default implementation of Object.getOwnPropertyNames to filter away the properties that act as a Symbol. It uses the original function to do so. Appearantly, that custom usage throws.

@ljharb
Copy link
Member

ljharb commented Jul 2, 2020

aha, interesting

@tmsns
Copy link
Author

tmsns commented Jul 2, 2020

aha, interesting

Yeah, I found that interesting as well. :-) It does remind me on how other polyfills also impact how devtools is behaving (eg. webcomponents polyfill) Had not seen it before on these smaller polyfills though. 😃

Let me know if you need more info, or clarifications.

@ljharb
Copy link
Member

ljharb commented Jul 2, 2020

We'll probably need a technique like in object-keys.

Easiest would be to depend directly on object-keys, but that would be best done in a major bump, since this package doesn't currently have deps, and it'd need a bit of restructuring to update it to modern approaches.

I'll look into possible solutions beyond just a try/catch.

@tmsns
Copy link
Author

tmsns commented Jul 2, 2020

The highlighted technique is an exclusion list. What exclusions were you thinking of?

Also, when you talk about depending on object-keys, do you mean using it instead of relying on the built-in Object.getOwnPropertyNames? Or did you have something else in mind?

Some extra things I noticed:

  • entering window or window.frames in the console throws as well (2x each)
  • entering Object.getOwnPropertyNames(window) or Object.getOwnPropertyNames(window.frames) doesn't

It seems as if the objects passed directly by the devtools to the function have some kind of lowered security context. 🤔

@ljharb
Copy link
Member

ljharb commented Aug 28, 2020

Yes, IE has some strange behaviors around this sort of thing.

We might even need something crazier where the gOPN wrapper temporarily restores the native function, calls it, and then reverts the native one back to the wrapper, so it can successfully call it.

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 a pull request may close this issue.

2 participants