HTML/JavaScript Script Injection Exception

1

I tried to write a bookmarklet which depends on another script. For this my bookmarklet includes a function like this:

function load(url, callback) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    script.async = false;
    script.onload = callback;
    document.head.appendChild(script);
}

The callback function is called on most pages, but on some pages I get the following exception in the console and the script is not loaded (facebook.com is one example).

Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE)

An example of a bookmarklet:

javascript:function%20load(url,callback){var%20script=document.createElement('script');script.type='text/javascript';script.src=url;script.onload=callback;document.head.appendChild(script);}load('http://code.jquery.com/jquery-1.11.1.min.js',function(){console.log('Loaded');})

I use FireFox 29 on Ubuntu 12.04. If it is executed a "Loaded" should a appear in the console. On the first load an additional access to the resource is visible in the console. But as written above on e.g. facebook.com nothing happens at all. Neither is the script loaded nor is the callback called.

javascript
firefox
exception
asked on Stack Overflow May 21, 2014 by Freya Thor • edited May 21, 2014 by Freya Thor

1 Answer

1

It was quite likely due to XSS from the bookmarklet itself. FF 35.0 doesn't have an error anymore and shows a well formatted message.

answered on Stack Overflow Feb 12, 2015 by Freya Thor

User contributions licensed under CC BY-SA 3.0