Your Search Results

    Working around the Firefox 1.0.3 DHTML regression

    The Problem

    Please note that the following issues have been fixed for the Firefox 1.0.4 release, and this document applies strictly to the 1.0.3 version of the browser.

    Changes were made in Firefox 1.0.3 that can cause the following error to arise on pages that would have worked properly in previous versions:

    Error: uncaught exception: [Exception... "Illegal operation
    on WrappedNative prototype object" 
    nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" 
    location: "JS frame :: file_url :: anonymous :: line 789"  data: no]

    If you are getting this error, there are two possible solutions.

    Changes were made in Firefox 1.0.3 that change how the content DOM is accessed from Chrome. These changes, and the changes you need to make to your code, are outlined in the Safely accessing content DOM from chrome.

    Solution/Workaround: If "file_url" is a non-Chrome .js or .html file

    If this is the case, then you have run into a bug we inadvertently introduced while making some major security fixes for Firefox 1.0.3. There is a workaround for this, as follows:

    Gecko-based browsers

    var elementProto = Element.prototype;
    elementProto.__proto__ = {
      get text() { return this.firstChild.nodeValue; },
      __proto__: elementProto.__proto__

    Note: The get text() {...} syntax will not work in non-Gecko browsers.

    All browsers

    var elementProto = Element.prototype;
    var elementGrandProto = elementProto.__proto__ = {
      __proto__: elementProto.__proto__
      function () { return this.firstChild.nodeValue; }

    Note: If you are trying to override a predefined prototype property, you may have to put these vanilla objects ahead of the DOM prototype, instead of after it as these examples do. In that case, be careful not to reset the DOM prototype for all browsers (you'll need to detect the user agent and reset Element.prototype only for Firefox 1.0.3; other browsers do not support __proto__, so do not allow insertion in an existing prototype chain).

    For more information

    For more information, see Bug 290777.

    Document Tags and Contributors

    Contributors to this page:
    Last updated by: mizandaniel,