[Windmill-dev] Facebook X-domain problem
Adam Christian
adam at osafoundation.org
Fri Jan 4 13:38:48 PST 2008
Alright, after lots of fussing around I think I have something that
works.
It isn't perfect, as I am getting some js complains from the
quicklogin facebook script but I am able to record and playback tests
and haven't seen anything not work correctly.
The solution I have checked in does the following:
When windmill is initially configured I store the domain we are testing.
When the remote is loaded, I stick that value into the remote so that
I can get at it.
When the loop is turned on for the first time I check to see if I can
access opener.document.domain, if I can't I take the hostname and rm
www. from it and set the document.domain. The reason that we can count
on this value being the domain minus the www is because facebook.com
(or blah.com) without the www is the only thing the browser will
actually let you set the domain to. You can't even set the domain back
to www.facebook.com (which is the default) even if you want to.
In all future page loads, I do this same check incase if this changes
somehow along the way.
I have recorded tests in firefox and safari and played them back
successfully. Since timing is a big issue here, you probably will get
some output in the windmill output the very first time the page loads
facebook.com as I try various binding routines to keep track of
loading, and once the page is fully loaded, if my loop isn't done I
try to access objects in the page that are now out of bounds until the
domain is fixed. I don't really see that as a huge issue at the moment
as it doesn't block usage after the loop is turned on for the first
time.
I also changed the status message, to "Please Wait.." so that people
know not to start recording or playing back or anything until the IDE
is ready.
For now I think this is the best I can do, please chime in with ideas
etc.
Adam
On Jan 3, 2008, at 9:01 PM, Matthew Eernisse wrote:
> How are you gentlemen.
>
> I found the culprit, in the very last three lines of base.js:
>
> if (navigator && navigator.userAgent &&
> !(parseInt((/Gecko\/([0-9]+)/.exec(navigator.userAgent)
> || []).pop()) <= 20060508)) {
> document.domain='facebook.com';
> }
>
> Probably doing it so it can see cookies set by pages from all the
> various subdomains. They're doing some kind of interesting user-
> agent sniffing in that conditional, weeding out Gecko-based browsers
> older than 2006-05-08. Not sure what the significance of that is.
>
> Naturally enough, if I reset the domain for the IDE to the same
> thing, I can load the IDE with no errors, and do recording/playback
> on the FB home page. I was resetting it in windmill.Start, right
> after the two windmill.service calls.
>
> This is going to be pretty annoying, because they're changing the
> domain *as* the JavaScript is loading and executing.
>
> Once they change the domain in the opener window out from under us,
> there's of course no way to get a handle on it with script to look
> up what it changed to. So I guess we need a way to pass a designated
> domain name from the backend to set the IDE window to before trying
> to grab the reference to the testWindow.
>
> It's kind of ugly, but anyone who wants to test their FB apps will
> need to do it.
>
>
> Matthew
>
> _______________________________________________
> Windmill-dev mailing list
> Windmill-dev at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/windmill-dev
More information about the Windmill-dev
mailing list