anfas
anfas

Reputation: 356

Firefox OS privileged app: Permission denied to access property 'document' of new window object created

In my Firefox OS privileged app I need authentication with Google.

uri=https://accounts.google.com/o/oauth2/auth............

var googleWin = window.open(uri, 'auth_window', 'fullscreen=0,width=200,height=100,resizable=1');


console.log(googleWin.document.title); 

The above statement which try to to print the document title result in error

Error: Permission denied to access property 'document'

I need to access the Google auth "code" from the document title.

How to solve the permission problem?

Thanks in advance.

Upvotes: 1

Views: 645

Answers (2)

Alex W
Alex W

Reputation: 38253

Because of the same origin security policy, you're not going to be able to access that window's DOM. In the documentation, they suggest using AJAX with your auth code and processing the response of that request.

Upvotes: 1

dreamerkumar
dreamerkumar

Reputation: 1550

You can't directly access the components of the window. But you can write a javascript function inside the child auth_window that can easily access every dom element and perform any operations that you need or return back values. Then from your parent window, just make calls to these javascript functions:

console.log(googleWin.getDocumentTitle());

Upvotes: 1

Related Questions