page never finishes loading

Bug reports and enhancement requests
Post Reply
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

page never finishes loading

Post by al_9x »

Fx 3.6.0, NS 1.9.9.53, new profile, defaults

1) go to http://www.kinopoisk.ru/
2) temp allow kinopoisk.ru
3) page reloads and stays in the loading state
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
Alan Baxter
Ambassador
Posts: 1586
Joined: Fri Mar 20, 2009 4:47 am
Location: Colorado, USA

Re: page never finishes loading

Post by Alan Baxter »

It finishes loading for me if I also TA:
217.16.18.163
217.16.18.207
94.103.92.145
adriver.ru
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

If blocking a particular resource prevents a page from reaching loaded state, that's probably a bug, Giorgio?
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: page never finishes loading

Post by Giorgio Maone »

al_9x wrote:If blocking a particular resource prevents a page from reaching loaded state, that's probably bug, Giorgio?
I'm investigating, but it's not necessarily a NoScript bug: the page may be checking whether a resource loads successfully in a certain timeframe and attempt a new load if it doesn't.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: page never finishes loading

Post by Giorgio Maone »

Giorgio Maone wrote:it's not necessarily a NoScript bug: the page may be checking whether a resource loads successfully in a certain timeframe and attempt a new load if it doesn't.
In fact, the same problem happen if you disable/uninstall NoScript and install ABP with Easylist.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

Ran into another site with this problem and decided to get to the bottom of this.

Here's a distillation:

Code: Select all

<script>
var iframe_id = 'iframe1';
document.write('<iframe id="' + iframe_id + '"></iframe>');
(function()
{
	var iframe, iframe_doc;
	if ((iframe = document.getElementById(iframe_id)) && (iframe_doc = iframe.contentDocument))
		iframe_doc.write('<script src="http://untrusted.invalid/"><\/script>');
	else
		setTimeout(arguments.callee, 100);
})();
</script>
Loading the above with NS results in perpetual loading state. This technique is utilized by http://www.adriver.ru/ and is in both sites.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: page never finishes loading

Post by Giorgio Maone »

al_9x wrote: Loading the above with NS results in perpetual loading state. This technique is utilized by http://www.adriver.ru/ and is in both sites.
There's not much I can do about it, aside surrogating a "contentDocument"property on NoScript's placeholder (and contentWindow? and contentWindow.document? and what about contentDocument.write()?) .
I'm not sure whether an iframe blocked by content policies has an accessible contentDocument either: does it work if you block the frame with ABP?
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

Giorgio Maone wrote:
al_9x wrote: Loading the above with NS results in perpetual loading state. This technique is utilized by http://www.adriver.ru/ and is in both sites.
There's not much I can do about it, aside surrogating a "contentDocument"property on NoScript's placeholder (and contentWindow? and contentWindow.document? and what about contentDocument.write()?) .
I'm not sure whether an iframe blocked by content policies has an accessible contentDocument either: does it work if you block the frame with ABP?
It's not clear from your response, can you repro this with the small test page from my previous post?

If so, do you understand what specifically is causing the perpetual loading state? Please explain. The iframe is not being blocked AFAICT, there are no placeholders. The script is successfully written to the iframe (confirmed by venkman and dom inspector) and blocked by NS.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

Giorgio Maone wrote:There's not much I can do about it, aside surrogating a "contentDocument"property on NoScript's placeholder (and contentWindow? and contentWindow.document? and what about contentDocument.write()?) .
I really don't understand what you're saying here. What placeholder? Anyway, I did identify the precise cause. In order for the the loading state to go to completion the document has to be closed. One of the doc.written external ad scripts does just that, but since it's blocked, the doc remains open.

It should be possible to fix this with a surrogate for the blocked script. It should probably test that it's in a doc.written frame before calling document.close() Is this the best approach?
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: page never finishes loading

Post by Giorgio Maone »

al_9x wrote:I really don't understand what you're saying here.
Sorry, I was assuming you were blocking the frame and the perpetual loading was due to a setTimeout() loop.

In your case, even though this is clearly a site bug and wouldn't deserve "fixing", a surrogate against the imported script will probably work.

You can try this:

noscript.surrogate.autoClose.sources

Code: Select all

untrusted.invalid
noscript.surrogate.autoClose.replacement

Code: Select all

if (top != self && top.location.href == location.href) setTimeout("try{document.close()}catch(e){}", 100)
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

Giorgio Maone wrote:
al_9x wrote:I really don't understand what you're saying here.
Sorry, I was assuming you were blocking the frame and the perpetual loading was due to a setTimeout() loop.
Even if setTimeout were looping it would not keep the doc in the loading state.
Giorgio Maone wrote:In your case, even though this is clearly a site bug and wouldn't deserve "fixing"
How is it a site bug? It only manifests when NS blocks the ad script that closes the document.

I'll make sure the surrogate is working for adriver.ru and post it, in case you decide to include it.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: page never finishes loading

Post by al_9x »

Code: Select all

user_pref("noscript.surrogate.adriver.sources", "ad.adriver.ru/cgi-bin/erle.cgi");
user_pref("noscript.surrogate.adriver.replacement", "if (top !== self && top.location.href === location.href) setTimeout('try{document.close();}catch(e){}', 100);");
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
Post Reply