What is and what is the exotic Windowproxy object for?

Asked

Viewed 37 times

4

While looking for good links to this answer, I came across a quote from an object called WindowProxy. In the search for explanations, I found this link with the definition:

A Windowproxy is an exotic Object that wraps a Window ordinary Object, indirecting Most Operations through to the Wrapped Object. Each browsing context has an Associated Windowproxy Object. When the browsing context is navigated, the Window Object Wrapped by the browsing context’s Associated Windowproxy Object is changed.

Translating:

A Windowproxy is an exotic object that surrounds a common Window object, directing most operations to the packaged object. Each browsing context has an associated Windowproxy object. When the browsing context is navigated (changed), the Window object involved by the Windowproxy object associated with the browsing context is changed.

What I understood:

...

I had never heard of this object. Nor if I found anything related here in Sopt.

In this link of the MDN, we have another quote:

The Window.self read-only Property Returns the window itself, as a Windowproxy. It can be used with dot Notation on a window Object (that is, window.self) or standalone (self).

From the little I understood of the above definition, this is an implementation that we don’t have direct contact with, it happens kind of "behind the scenes".

Each window is associated with windowProxy and when you work with the window, is not the object window in fact, but rather a representation of the window that changes every browsing context, a WindowProxy. Which in a way makes sense. For example the code below:

My statement above is a deduction. I’m not sure if this is right.

function a () {
  if (!window.teste) {
    window.teste = 'Olá!'
  } else {
    console.log('window.teste já foi definido!');
  }
}

a();

console.log(window.teste);

If I reload the page, the console.log('window.teste já foi definido!'); will never be executed as the context has changed and a new WindowProxy was created, or associated (do not know).

I am assuming that this object is not very useful, or has no importance for development in applications in browsers, and of course I cannot say for sure. I would like to know at least a little about the subject and if my explanation above is correct. Maybe someone will inform that it has no importance/usefulness this WindoProxy and it’s just a concept about execution context for the window.


Lack of links, including the MDN Web Docs (Windowproxy appears in red, indicating missing link).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.