When is the original JavaScript prototype used with frames of the same origin?

Today I noticed that for some iframes www.cnn.com ( window[0]in the example) they have

Array.prototype === window[0].Array.prototype

Of course, from within the frame they also have

Array.prototype === top.Array.prototype

the same applies to Object, Functionetc. But I can not find any information about this behavior, and I can not reproduce it if I create plunkr with the same original iframe. On the main page and in the frame, both parameters document.domainare equal cnn.com, but this also does not help in my case. Array.prototypeis not configurable, so it’s not clear to me how this can be done specifically with the script. I experienced this (but could not play it) on FF 29 and not on Chrome 33.

+4
source share
1 answer

I am confused about what your question is, but I assume that you are asking why you need to share prototypes of your own objects between frames. In a normal situation, you wouldn’t do this, and this condition will take place. false == (<Iframe>.window.Array.prototype === window.Array.prototype)I assume that they are trying to make this condition be true in the documents. My instinct about this says that somewhere in the guts of their code they need this conditional to evaluate the "truth". Sounds like a hack.

+1
source

Source: https://habr.com/ru/post/1531657/


All Articles