continuing to fail at surrogates

Ask for help about NoScript, no registration needed to post
TooCrooked
Posts: 19
Joined: Sun May 02, 2010 9:51 pm

continuing to fail at surrogates

Post by TooCrooked »

i want to simply alert "test" using a fallback surrogate. i created an HTML file on my desktop and added the following line to my user.js file:

Code: Select all

user_pref("noscript.surrogate.test.replacement", "addEventListener('DOMContentLoaded', function(ev) { alert('test')}, true)");
user_pref("noscript.surrogate.test.sources", "!*");
the reason it's formatted that way is because i was trying to use something provided to me in this thread:

http://forums.informaction.com/viewtopi ... 370#p18370

of course, since the file is on my desktop, noscript defaultly automatically blocks JS from running (which i dont like, but i digress)

why can i never get these to work!!! (rhretorical final statement)
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: continuing to fail at surrogates

Post by Giorgio Maone »

TooCrooked wrote:i want to simply alert "test" using a fallback surrogate. i created an HTML file on my desktop and added the following line to my user.js file:

Code: Select all

user_pref("noscript.surrogate.test.replacement", "addEventListener('DOMContentLoaded', function(ev) { alert('test')}, true)");
user_pref("noscript.surrogate.test.sources", "!*");
The main problem here is that "fallback" surrogates (those with a "!" in their sources) are already executed in a DOMContentLoaded event handler, therefore yours will never run because gets registered too late.
Just drop the addEventListener call and put your code directly at the top level.
TooCrooked wrote: of course, since the file is on my desktop, noscript defaultly automatically blocks JS from running (which i dont like, but i digress)
You'd just need to allow file://

[EDIT]
Surrogates don't run on file:// URLs, as al_9x noted and I, instead, forgot (see below).
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
al_9x
Master Bug Buster
Posts: 931
Joined: Thu Mar 19, 2009 4:52 pm

Re: continuing to fail at surrogates

Post by al_9x »

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: continuing to fail at surrogates

Post by Giorgio Maone »

al_9x wrote:appears to have affected ! surrogates, they don't run on file: pages. By design?
Yes and no. Since they don't need to run that early, they could actually be applied to all kinds of page.
But for consistency and lower complexity, they (currently) have the same destiny as normal surrogates (this, like many other things, may or may not change post-Firefox 4).
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
Post Reply