Handle js request to window.opener ?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Handle js request to window.opener ?

Postby ZorroHorro » Thu Apr 12, 2018 7:53 am

Hi, im wanna get something like OnWindowOpenerRequest, how can I do this ? Also, maybe one knows, how can i handle window.location.href='http://google.com' or window.opener.location.href='http://google.com' to determinate that it was really from js and from opener
ZorroHorro
Techie
 
Posts: 13
Joined: Fri Mar 25, 2016 2:33 am

Re: Handle js request to window.opener ?

Postby magreenblatt » Thu Apr 12, 2018 11:26 am

What specifically are you trying to do?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Handle js request to window.opener ?

Postby ZorroHorro » Thu Apr 12, 2018 1:01 pm

I want to log all attempts to (read,write) window.opener, window.location. window.opener.location
ZorroHorro
Techie
 
Posts: 13
Joined: Fri Mar 25, 2016 2:33 am

Re: Handle js request to window.opener ?

Postby magreenblatt » Thu Apr 12, 2018 1:04 pm

You can override the functions in JavaScript to add logging. Google for examples.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Handle js request to window.opener ?

Postby ZorroHorro » Thu Apr 12, 2018 1:27 pm

Yes,i already do this

var func = window.location;
Object.defineProperty(window, 'location', { get: function() { console.log('href detected'); return func; }});

Uncaught TypeError: Cannot redefine property: location
at Function.defineProperty (<anonymous>)
at <anonymous>:1:35

:(

Maybe you can suggest something ?

I think that it cant be done becasuse a security alert ( https://www.mozilla.org/en-US/security/ ... sa2012-59/ - its all about firefox, but i think that its a the same issue)
ZorroHorro
Techie
 
Posts: 13
Joined: Fri Mar 25, 2016 2:33 am

Re: Handle js request to window.opener ?

Postby magreenblatt » Thu Apr 12, 2018 1:47 pm

magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Handle js request to window.opener ?

Postby ZorroHorro » Thu Apr 12, 2018 2:04 pm

its didnt work in global space


var _window = window;
var window = {};

Object.defineProperty(window, 'location', {
get: function () { return _window.location; },
set: function () { alert('not in my house'); }
});

window.__proto__ = _window;

// At this point, 'window' is identical to normal window except
// we've overriden its location property to be read-only.

// If you could manage to run your page's environment here, you could
// intercept attempts to change the page.

window.location = "blah"; // alerts 'not in my house'

VM3483:5 Uncaught TypeError: Cannot redefine property: location
at Function.defineProperty (<anonymous>)
at <anonymous>:5:12
ZorroHorro
Techie
 
Posts: 13
Joined: Fri Mar 25, 2016 2:33 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 95 guests