Page 1 of 1

continuing to fail at surrogates

Posted: Sat Jul 17, 2010 3:41 pm
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)

Re: continuing to fail at surrogates

Posted: Sat Jul 17, 2010 4:14 pm
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).

Re: continuing to fail at surrogates

Posted: Sat Jul 17, 2010 4:20 pm
by al_9x

Re: continuing to fail at surrogates

Posted: Sat Jul 17, 2010 4:33 pm
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).