# Access "name" attribute of the window in window.wrappedJSObject

**URL:** <https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431>\
**Category:** Development\
**Created:** [May 1, 2016, 11:30pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431 "2016-05-01T23:30:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasdev](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rasdev/32/4877_2.png) [@rasdev](https://discourse.mozilla.org/u/rasdev)\
**Post date:** [May 1, 2016, 11:30pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/1 "2016-05-01T23:30:39Z")

</div>

Hi everyone. I’m trying to access the name attribute of a window but I’m unsure of the correct syntax in this case due to the wrapped object. I’m doing this in a script executed by a frame script.

```
 Object.defineProperty(window.wrappedJSObject["Self"].prototype,
 "name",
 {
     writable: true,
     value: "test"
});

```

Accessing others such as the navigator via the wrapped object works fine .

Any ideas ?

Thanks

---

<div class="post-metadata">

**Author:** ![rasdev](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rasdev/32/4877_2.png) [@rasdev](https://discourse.mozilla.org/u/rasdev)\
**Post date:** [May 13, 2016, 1:59pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/2 "2016-05-13T13:59:40Z")

</div>

To clarify I’m trying to override window properties from a frame script. I have successfully modified the navigator and screen properties of a window but I also need to modify the name and inner/outer width/height properties of the window itself using frame scripts .

The only way I could get the screen and navigator interfaces to work was using window.wrappedJSObject but now I need to attributes of the window object directly.

Has anyone got any ideas of how I could modify those properties inside a frame script ?

---

<div class="post-metadata">

**Author:** ![rasdev](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rasdev/32/4877_2.png) [@rasdev](https://discourse.mozilla.org/u/rasdev)\
**Post date:** [May 23, 2016, 12:41pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/3 "2016-05-23T12:41:15Z")

</div>

[window.name](http://window.name) = “whatever” worked inside a frame script if anyone else is wondering. I still need to figure out how to modify the size attributes of the window but I will deal with that in a new issue.

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [May 23, 2016, 12:43pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/4 "2016-05-23T12:43:46Z")

</div>

Aw man no one came to help you out. It’s nice to see you made progress.

Tapping into the scope with `wrappedJSObject` will do the trick. I prefer not to do that though. I set up a messaging comm layer, and postMessage to the window, which returns to me the value.

---

<div class="post-metadata">

**Author:** ![rasdev](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rasdev/32/4877_2.png) [@rasdev](https://discourse.mozilla.org/u/rasdev)\
**Post date:** [May 23, 2016, 12:44pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/5 "2016-05-23T12:44:24Z")

</div>

Hi noitidart. It’s not exactly the standard use case so I did not imagine that too many people would have tried something similar. Using your approach can you modify the window size properties such as innerheight, outerwidth and so on ?

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [May 23, 2016, 12:51pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/6 "2016-05-23T12:51:32Z")

</div>

I send a message to the contentWindow, the message is a method name i defined in the contentWindow scope. So the message i send from the framscript triggers this function, which can do anything it wants as its in the same scope.

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [May 23, 2016, 12:54pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/7 "2016-05-23T12:54:16Z")

</div>

I haven’t made it totally ready so you can copy paste (im actually working on making this a clean api right now), but this is my comm layer -

basically it calls a function in the other side B, and triggers a callback with the return value in side A (the triggering side).

framescript side:  
[https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/MainFramescript.js#L213-L292](https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/MainFramescript.js#L213-L292)

And then contentwindow side:  
[https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/fsReturnIconset.js#L345-L445](https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/fsReturnIconset.js#L345-L445)

---

<div class="post-metadata">

**Author:** ![rasdev](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rasdev/32/4877_2.png) [@rasdev](https://discourse.mozilla.org/u/rasdev)\
**Post date:** [May 23, 2016, 12:50pm UTC](https://discourse.mozilla.org/t/access-name-attribute-of-the-window-in-window-wrappedjsobject/8431/8 "2016-05-23T12:50:45Z")

</div>

I’ll have to look into something like that if I can’t get window size to work. Thanks
