It's first a good idea to look at the line of code mentioned in the error message. Here it is resource://gre/modules/commonjs/sdk/content/content-worker.js
, line 81 - this is Add-on SDK code integrated into the browser. In Firefox 26 this line says:
let str = JSON.stringify(args, replacer);
This code belongs to the messaging mechanism of content workers. toJSON
is being called implicitly by JSON.stringify
on the objects that are being serialized.
Obviously, accessing xmlhttp.responseXML
doesn't trigger any content worker events. However, console.log()
does - right below the problematic createPipe
method in content-worker.js
you can see an injectConsole
method. This one provides console
API for content workers, and it will use messaging to forward any calls to the main extension code.
At that point the issue should be obvious: even though the "real" console.log()
method can deal with parameters of type XMLDocument
, the one provided to content workers cannot - it expects an object that can be serialized to JSON. Calling console.log(xmlhttp.responseText)
should work however. Also, console.log(new XMLSerializer.serializeToString(xmlhttp.responseXML))
might work (I'm not sure whether the XMLSerializer
constructor is defined in the worker context).