XPCNativeWrapper

  • Revision slug: XPCNativeWrapper
  • Revision title: XPCNativeWrapper
  • Revision id: 93047
  • Created:
  • Creator: Bzbarsky
  • Is current revision? No
  • Comment

Revision Content

XPCNativeWrapper is a way to wrap up an object so that it's safe to access from privileged code. It can be used in all Firefox versions, though the behavior changed somewhat starting with Firefox 1.5 (Gecko 1.8). See the entry for XPCNativeWrapper at the MozillaZine KnowledgeBase for the behavior of XPCNativeWrapper in Firefox versions prior to 1.5. This document addresses XPCNativeWrapper in Firefox 1.5 and later.

What XPCNativeWrapper does

An XPCNativeWrapper limits access to the properties and methods of the object it wraps. The only properties and methods accessible through an XPCNativeWrapper are those that are defined in IDL or defined by DOM Level 0 (though some DOM Level 0 properties and methods do not work on an XPCNativeWrapper. In particular, properties added to an object via JavaScript are not exposed by an XPCNativeWrapper for this object, and nor are getters and setters defined with __defineGetter__ and __defineSetter. The intent is to allow safe access to the IDL-defined methods of the object.

Types of XPCNativeWrapper

There are three different types of XPCNativeWrapper in Firefox 1.5. All three types wrap a possibly-unsafe object and provide safe access to its properties and methods.

The differences in behavior between the three types of XPCNativeWrapper are determined by two characteristics an XPCNativeWrapper wrapper can have. An XPCNativeWrapper can be explicit (or the opposite, implicit) and can be deep (or the opposite, shallow). The type of wrapper created is determined by the way it was created as follows:

Created by Explicit/Implicit Deep/Shallow
Protected script accessing an untrusted object Implicit Deep
Constructor called with string arguments Explicit Shallow
Constructor called with no string arguments Explicit Deep

Explicit vs. Implicit

The difference in behavior between explicit and implicit XPCNativeWrapper is that a property access on an implicit XPCNativeWrapper from script that is not protected is NOT safe. The property access will be forwarded through to the wrappedJSObject of the XPCNativeWrapper.

This means that scripts that are not protected don't need to worry about bugs arising because other code hands them an implicit XPCNativeWrapper. On the other hand, such scripts do need to watch out for unsafe object access.

Property access on an explicit XPCNativeWrapper is safe no matter whether the caller is protected.

Deep vs. Shallow

The difference in behavior between deep and shallow XPCNativeWrapper is that when a property is accessed or a function is called on a deep wrapper the return value will be wrapped in a XPCNativeWrapper of its own. The new XPCNativeWrapper will also be deep and it will be explicit if and only if the XPCNativeWrapper whose property is accessed was explicit. By contrast, when a property is accessed or a function is called on a shallow wrapper, the return value may be an unsafe object.

For example, say we are given three instances of XPCNativeWrapper for the same window object. Let us call them deepExplicitWindow, deepImplicitWindow and shallowWindow. Then we have:

var doc1 = deepExplicitWindow.document;
// doc1 is now a deep explicit XPCNativeWrapper for
// the document object.  Accessing doc1.open(), say, is safe.
var doc2 = deepImplicitWindow.document;
// If the caller has xpcnativewrappers=yes set, doc2 is now a deep
// implicit XPCNativeWrapper for the document object.
// Otherwise doc2 is now the unsafe document object, since the
// property access was simply passed along to the unsafe window object.
var doc3 = shallowWindow.document;
// doc3 is now the unsafe document object.

Creating XPCNativeWrapper objects

There are three different ways of creating an XPCNativeWrapper object; one way for each of the three types.

Protected script accessing an untrusted object

Any time a protected script accesses an untrusted object it will get back an implicit deep XPCNativeWrapper. Accessing properties of this XPCNativeWrapper is safe from protected scripts, and the return values will also be wrapped in implicit deep XPCNativeWrapper objects.

A wrapper created in this way will stick around as long as the object being wrapped does and accessing an object twice in a row will give the same XPCNativeWrapper.

What is a protected script?

A script is protected or not protected based in its URI. A script is trusted only if its URI starts with a known protected prefix. The protected prefixes in Firefox 1.5 are determined by the Chrome Registry.

By default, all content packages are protected. This means that all URIs that start "<tt>chrome://<package name>/content/</tt>" (for any package) are protected. Individual packages can override this using a flag in their chrome manifest file.

What is an untrusted object?

All objects are either trusted or untrusted. An object is trusted if any of the following hold:

  1. Its parent (__parent__ property in JavaScript) is a trusted object.
  2. It is the root scope object for a JavaScript component.
  3. It is the window object for a trusted window.

Since all DOM objects in a window have it on their __parent__ chain, they will be trusted if and only if their window is trusted.

What is a trusted window?

Whether a window is trusted depends on its container. A window is trusted if any of the following holds:

  1. It is a top-level window (e.g. <xul:window>, <xul:dialog>, or some URI passed to the <tt>-chrome</tt> command-line flag).
  2. Its parent is trusted, and one of the following three options holds:
    1. It is not loaded in a <xul:iframe> or <xul:browser>.
    2. The <xul:iframe> or <xul:browser> loading it doesn't have a "type" attribute.
    3. The value of the "type" attribute of the <xul:iframe> or <xul:browser> loading it is not "content" and does not start with "content-".

Note that whether a window is trusted does not depend on the URI loaded in the window. So for example, the following would create trusted windows when used inside a document whose window is already trusted:

  • <xul:browser>
  • <xul:browser type="chrome">
  • <xul:browser type="rabid_dog">
  • <xul:iframe type="foofy">
  • <html:iframe>
  • <html:iframe type="content">

The following would not create trusted windows:

  • <xul:browser type="content">
  • <xul:iframe type="content-primary">

Further note that any child window of an untrusted window is automatically untrusted.

What happens when a script accesses an object?

The table below describes what happens when a script accesses an object, and how the wrapper is involved.

Script Object Effects
Protected Trusted No wrapper is created and thereforce the script gets full access to the object.
Protected Untrusted An implicit deep XPCNativeWrapper is created.
Unprotected Trusted No wrapper is created, just as in the protected/trusted case.
Unprotected Untrusted No wrapper is created, just as in the protected/trusted case.

XPCNativeWrapper constructor call with string arguments

For example:

var contentWinWrapper = new XPCNativeWrapper(content,
                                             "document");

This creates an explicit shallow XPCNativeWrapper. This syntax has been kept for compatibility with versions prior to Firefox 1.5. While all properties of the contentWinWrapper object can now be safely accessed, the return values of these properties are NOT safe to access (just like in versions prior to Firefox 1.5), since the XPCNativeWrapper is shallow. So to compare the content document title to the current content selection, one must do:

var winWrapper = new XPCNativeWrapper(content, "document",
                                      "getSelection()");
var docWrapper = new XPCNativeWrapper(winWrapper.document,
                                      "title");
return docWrapper.title == winWrapper.getSelection();

just like in versions before Firefox 1.5. Note that the "getSelection()" argument is not strictly needed here; if the code is not intended for use with Firefox versions before 1.5 it can be removed. A single string argument after the object being wrapped is all that is required for Firefox 1.5 to create this type of XPCNativeWrapper.

XPCNativeWrapper constructor call with no string arguments

For example:

var contentWinWrapper = new XPCNativeWrapper(content);

This creates an explicit deep XPCNativeWrapper. Accessing properties of this XPCNativeWrapper is safe, and the return values will also be wrapped in explicit deep XPCNativeWrapper objects.

Setting "expando" properties on XPCNativeWrapper

It is possible to set "expando" properties (properties with names that don't correspond to IDL-defined properties) on XPCNativeWrapper objects. If this is done, then chrome will be able to see these expando properties, but content will not be able to. There is no safe way to set an expando property from chrome and have it be readable from content.

XPCNativeWrapper lifetime

Explicit XPCNativeWrapper objects exist while they are referenced. Creating a new explicit XPCNativeWrapper for the same possibly-unsafe object will create a new wrapper object; something to watch out for when setting "expando" properties

Implicit XPCNativeWrapper objects have the same lifetime as the object they're wrapping.

Accessing unsafe properties

If unsafe access to a property is required for some reason, this can be accomplished via the wrappedJSObject property of the wrapper. For example, if docWrapper is a wrapper for doc, then

docWrapper.wrappedJSObject.prop

is the same as

doc.prop

Limitations of XPCNativeWrapper

There are some commonly used properties and coding styles that cannot be used with XPCNativeWrapper. Specifically:

  1. Assigning to or reading an on* property on an XPCNativeWrapper of a DOM node or Window object will throw an exception.
  2. Access to frames by window name (e.g. window.frameName) does not work on an XPCNativeWrapper
  3. document.all does not work on an XPCNativeWrapper for a document.
  4. Access to named items by name does not work on an XPCNativeWrapper for an HTML document. For example, if you have a <form name="foo"> and docWrapper is a wrapper for the HTML document doc then doc.foo is an HTMLFormElement while docWrapper.foo is undefined. Code that wishes to do this could use docWrapper.forms{{mediawiki.external('\"foo\"')}} instead.
  5. Access to nodes by id doesn't work on an XPCNativeWrapper for an HTML document. getElementById should be used instead.
  6. Access to inputs by name doesn't work on an XPCNativeWrapper for an HTML form. Code that wishes to do this should use form.elements{{mediawiki.external('\"inputname\"')}}.
  7. Calling methods implemented by NPAPI plugins through the XPCNativeWrapper for the corresponding node does not work.
  8. Getting or setting properties implemented by NPAPI plugins though the XPCNativeWrapper for the corresponding node does not work.
  9. Calling methods implemented via XBL bindings attached to a node through an XCPNativeWrapper for that node does not work.
  10. Getting or setting properties implemented via XBL bindings attached to a node through an XCPNativeWrapper for that node does not work.
  11. Enumerating the properties of an XPCNativeWrapper via "for (var p in wrapper)" does not enumerate the IDL-defined properties.
  12. Object.prototype is not on the prototype chain of an XPCNativeWrapper. As a result, various Object.prototype properties are undefined on an XPCNativeWrapper (to be precise, these are __proto__, __parent__, __count__, toSource, toLocaleString, valueOf, watch, unwatch, hasOwnProperty, isPrototypeOf, propertyIsEnumerable, __defineGetter__, __defineSetter__, __lookupGetter__, and __lookupSetter__).
  13. There is no support for the importXPCNative method the old XPCNativeWrapper implementation used to have.

Revision Source

<p><code>XPCNativeWrapper</code> is a way to wrap up an object so that it's safe to access from privileged code.  It can be used in all Firefox versions, though the 
behavior changed somewhat starting with Firefox 1.5 (Gecko 1.8).  See <a class="external" href="http://kb.mozillazine.org/XPCNativeWrapper">the entry for <code>XPCNativeWrapper</code> at the MozillaZine KnowledgeBase</a> for the behavior of <code>XPCNativeWrapper</code> in Firefox versions prior to 1.5.  This document addresses <code>XPCNativeWrapper</code> in Firefox 1.5 and later.
</p>
<h3 name="What_XPCNativeWrapper_does"> What <code>XPCNativeWrapper</code> does </h3>
<p>An <code>XPCNativeWrapper</code> limits access to the properties and methods of the object it wraps.  The only properties and methods accessible through an <code>XPCNativeWrapper</code> are those that are defined in IDL or defined by DOM Level 0 (though some DOM Level 0 properties and methods <a href="#Limitations_of_XPCNativeWrapper">do not work on an <code>XPCNativeWrapper</code></a>.  In particular, properties added to an object via JavaScript are not exposed by an <code>XPCNativeWrapper</code> for this 
object, and nor are getters and setters defined with <code>__defineGetter__</code> and <code>__defineSetter</code>.  The intent is to allow safe access to the IDL-defined methods of the object.
</p>
<h3 name="Types_of_XPCNativeWrapper"> Types of <code>XPCNativeWrapper</code> </h3>
<p>There are three different types of <code>XPCNativeWrapper</code> in Firefox 1.5.  All three types wrap a possibly-unsafe object and <a href="#What_XPCNativeWrapper_does">provide safe access to its properties and methods</a>.
</p><p>The differences in behavior between the three types of <code>XPCNativeWrapper</code> are determined by two characteristics an <code>XPCNativeWrapper</code> wrapper can have.  An <code>XPCNativeWrapper</code> can be <a href="#Explicit_vs._Implicit"><i>explicit</i></a> (or the opposite, <i>implicit</i>) and can be <a href="#Deep_vs._Shallow"><i>deep</i></a> (or the opposite, <i>shallow</i>).  The type of wrapper created is determined by <a href="#Creating_XPCNativeWrapper_objects">the way it was created</a> as follows:
</p>
<table border="1">
<tbody><tr>
<th> Created by
</th><th> Explicit/Implicit
</th><th> Deep/Shallow
</th></tr>
<tr>
<th> <a href="#Protected_scripe_accessing_an_untrusted_object">Protected script accessing an untrusted object</a>
</th><td> Implicit
</td><td> Deep
</td></tr>
<tr>
<th> <a href="#XPCNativeWrapper_constructor_call_with_string_arguments">Constructor called with string arguments</a>
</th><td> Explicit
</td><td> Shallow
</td></tr>
<tr>
<th> <a href="#XPCNativeWrapper_constructor_call_with_no_string_arguments">Constructor called with no string arguments</a>
</th><td> Explicit
</td><td> Deep
</td></tr></tbody></table>
<h4 name="Explicit_vs._Implicit"> Explicit vs. Implicit </h4>
<p>The difference in behavior between explicit and implicit <code>XPCNativeWrapper</code> is that a property access on an implicit <code>XPCNativeWrapper</code> from script that is not <a href="#What_is_a_protected_script.3F">protected</a> is NOT safe.  The property access will be forwarded through to the <code>wrappedJSObject</code> of the <code>XPCNativeWrapper</code>.
</p><p>This means that scripts that are not <a href="#What_is_a_protected_script.3F">protected</a> don't need to worry about bugs arising because other code hands them an implicit <code>XPCNativeWrapper</code>.  On the other hand, such scripts do need to watch out for unsafe object access.
</p><p>Property access on an explicit <code>XPCNativeWrapper</code> is safe no matter whether the caller is <a href="#What_is_a_protected_script.3F">protected</a>.
</p>
<h4 name="Deep_vs._Shallow"> Deep vs. Shallow </h4>
<p>The difference in behavior between deep and shallow <code>XPCNativeWrapper</code> is that when a property is accessed or a function is called on a deep wrapper the return value will be wrapped in a <code>XPCNativeWrapper</code> of its own.  The new <code>XPCNativeWrapper</code> will also be deep and it will be <a href="#Explicit_vs._Implicit">explicit</a> if and only if the <code>XPCNativeWrapper</code> whose property is accessed was explicit. By contrast, when a property is accessed or a function is called on a shallow wrapper, the return value may be an unsafe object.
</p><p>For example, say we are given three instances of <code>XPCNativeWrapper</code> for the same window object.  Let us call them <code>deepExplicitWindow</code>, <code>deepImplicitWindow</code> and <code>shallowWindow</code>.  Then we have:
</p>
<pre class="eval">var doc1 = deepExplicitWindow.document;
// doc1 is now a deep explicit <code>XPCNativeWrapper</code> for
// the document object.  Accessing doc1.open(), say, is safe.
</pre>
<pre class="eval">var doc2 = deepImplicitWindow.document;
// If the caller has xpcnativewrappers=yes set, doc2 is now a deep
// implicit <code>XPCNativeWrapper</code> for the document object.
// Otherwise doc2 is now the unsafe document object, since the
// property access was simply passed along to the unsafe window object.
</pre>
<pre class="eval">var doc3 = shallowWindow.document;
// doc3 is now the unsafe document object.
</pre>
<h3 name="Creating_XPCNativeWrapper_objects"> Creating <code>XPCNativeWrapper</code> objects </h3>
<p>There are three different ways of creating an <code>XPCNativeWrapper</code> object; one way for each of the three types.
</p>
<h4 name="Protected_script_accessing_an_untrusted_object"> Protected script accessing an untrusted object </h4>
<p>Any time a <a href="#What_is_a_protected_script.3F">protected script</a> accesses an <a href="#What_is_an_untrusted_object.3F">untrusted object</a> it will get back an <a href="#Explicit_vs._Implicit">implicit</a> <a href="#Deep_vs._Shallow">deep</a> <code>XPCNativeWrapper</code>.  Accessing properties of this <code>XPCNativeWrapper</code> is safe from <a href="#What_is_a_protected_script.3F">protected scripts</a>, and the return values will also be wrapped in <a href="#Explicit_vs._Implicit">implicit</a> <a href="#Deep_vs._Shallow">deep</a> <code>XPCNativeWrapper</code> objects.
</p><p>A wrapper created in this way will stick around as long as the object being wrapped does and accessing an object twice in a row will give the same <code>XPCNativeWrapper</code>.
</p>
<h5 name="What_is_a_protected_script.3F"> What is a protected script? </h5>
<p>A script is protected or not protected based in its URI.  A script is trusted only if its URI starts with a known protected prefix.  The protected prefixes in Firefox 1.5 are determined by the Chrome Registry.
</p><p>By default, <b>all content packages are protected</b>. This means that all URIs that start "<tt>chrome://&lt;package name&gt;/content/</tt>" (for any package) are protected.  Individual packages can <a href="en/Chrome_Registration#xpcnativewrappers">override this using a flag</a> in their chrome manifest file.
</p>
<h5 name="What_is_an_untrusted_object.3F"> What is an untrusted object? </h5>
<p>All objects are either trusted or untrusted.  An object is trusted if any of the following hold:
</p>
<ol><li> Its parent (<code>__parent__</code> property in JavaScript) is a trusted object.
</li><li> It is the root scope object for a JavaScript component.
</li><li> It is the window object for a <a href="en/What_is_a_trusted_window.3F">trusted window</a>.
</li></ol>
<p>Since all DOM objects in a window have it on their __parent__ chain, they will be trusted if and only if their window is trusted.
</p>
<h5 name="What_is_a_trusted_window.3F"> What is a trusted window? </h5>
<p>Whether a window is trusted depends on its container.  A window is trusted if any of the following holds:
</p>
<ol><li> It is a top-level window (e.g. <code>&lt;xul:window&gt;</code>, <code>&lt;xul:dialog&gt;</code>, or some URI passed to the <tt>-chrome</tt> command-line flag).
</li><li> Its parent is trusted, and one of the following three options holds:
<ol><li> It is not loaded in a <code>&lt;xul:iframe&gt;</code> or <code>&lt;xul:browser&gt;</code>.
</li><li> The <code>&lt;xul:iframe&gt;</code> or <code>&lt;xul:browser&gt;</code> loading it doesn't have a "type" attribute.
</li><li> The value of the "type" attribute of the <code>&lt;xul:iframe&gt;</code> or <code>&lt;xul:browser&gt;</code> loading it is not "content" and does not start with "content-".
</li></ol>
</li></ol>
<p>Note that whether a window is trusted does <b>not</b> depend on the URI loaded in the window. So for example, the following would create trusted windows when used inside a document whose window is already trusted:
</p>
<ul><li> <code>&lt;xul:browser&gt;</code>
</li><li> <code>&lt;xul:browser type="chrome"&gt;</code>
</li><li> <code>&lt;xul:browser type="rabid_dog"&gt;</code>
</li><li> <code>&lt;xul:iframe type="foofy"&gt;</code>
</li><li> <code>&lt;html:iframe&gt;</code>
</li><li> <code>&lt;html:iframe type="content"&gt;</code>
</li></ul>
<p>The following would not create trusted windows:
</p>
<ul><li> <code>&lt;xul:browser type="content"&gt;</code>
</li><li> <code>&lt;xul:iframe type="content-primary"&gt;</code>
</li></ul>
<p>Further note that any child window of an untrusted window is automatically untrusted.
</p>
<h5 name="What_happens_when_a_script_accesses_an_object.3F"> What happens when a script accesses an object? </h5>
<p>The table below describes what happens when a script accesses an object, and how the wrapper is involved.
</p>
<table border="1">
<tbody><tr>
<th> Script
</th><th> Object
</th><th> Effects
</th></tr>
<tr>
<td> Protected </td><td> Trusted </td><td> No wrapper is created and thereforce the script gets full access to the object.
</td></tr>
<tr>
<td> Protected </td><td> Untrusted </td><td> An <a href="#Explicit_vs._Implicit">implicit</a> <a href="#Deep_vs._Shallow">deep</a> <code>XPCNativeWrapper</code> is created.
</td></tr>
<tr>
<td> Unprotected </td><td> Trusted </td><td> No wrapper is created, just as in the protected/trusted case.
</td></tr>
<tr>
<td> Unprotected </td><td> Untrusted </td><td> No wrapper is created, just as in the protected/trusted case.
</td></tr></tbody></table>
<h4 name="XPCNativeWrapper_constructor_call_with_string_arguments"> <code>XPCNativeWrapper</code> constructor call with string arguments </h4>
<p>For example:
</p>
<pre class="eval">var contentWinWrapper = new XPCNativeWrapper(content,
                                             "document");
</pre>
<p>This creates an <a href="#Explicit_vs._Implicit">explicit</a> <a href="#Deep_vs._Shallow">shallow</a> <code>XPCNativeWrapper</code>.  This syntax has been kept for compatibility with versions prior to Firefox 1.5.  While all properties of the <code>contentWinWrapper</code> object can now be safely accessed, the return values of these properties are NOT safe to access (just like in versions prior to Firefox 1.5), since the <code>XPCNativeWrapper</code> is <a href="#Deep_vs._Shallow">shallow</a>.  So to compare the content document title to the current content selection, one must do:
</p>
<pre class="eval">var winWrapper = new XPCNativeWrapper(content, "document",
                                      "getSelection()");
var docWrapper = new XPCNativeWrapper(winWrapper.document,
                                      "title");
return docWrapper.title == winWrapper.getSelection();
</pre>
<p>just like in versions before Firefox 1.5.  Note that the <code>"getSelection()"</code> argument is not strictly needed here; if the code is not intended for use with Firefox versions before 1.5 it can be removed.  A single string argument after the object being wrapped is all that is required for Firefox 1.5 to create this type of <code>XPCNativeWrapper</code>.
</p>
<h4 name="XPCNativeWrapper_constructor_call_with_no_string_arguments"> <code>XPCNativeWrapper</code> constructor call with no string arguments </h4>
<p>For example:
</p>
<pre class="eval">var contentWinWrapper = new XPCNativeWrapper(content);
</pre>
<p>This creates an <a href="#Explicit_vs._Implicit">explicit</a> <a href="#Deep_vs._Shallow">deep</a> <code>XPCNativeWrapper</code>.  Accessing properties of this <code>XPCNativeWrapper</code> is safe, and the return values will also be wrapped in 
<a href="#Explicit_vs._Implicit">explicit</a> <a href="#Deep_vs._Shallow">deep</a> <code>XPCNativeWrapper</code> objects.
</p>
<h3 name="Setting_.22expando.22_properties_on_XPCNativeWrapper"> Setting "expando" properties on <code>XPCNativeWrapper</code> </h3>
<p>It is possible to set "expando" properties (properties with names that don't correspond to IDL-defined properties) on <code>XPCNativeWrapper</code> objects.  If this is done, then chrome will be able to see these expando properties, but content will not be able to.  <b>There is no safe way to set an expando property from chrome and have it be readable from content.</b>
</p>
<h3 name="XPCNativeWrapper_lifetime"> <code>XPCNativeWrapper</code> lifetime </h3>
<p>Explicit <code>XPCNativeWrapper</code> objects exist while they are referenced.  Creating a new explicit <code>XPCNativeWrapper</code> for the same possibly-unsafe object will create a new wrapper object; something to watch out for when <a href="#Setting_.22expando.22_properties_on_XPCNativeWrapper">setting "expando" properties</a>
</p><p>Implicit <code>XPCNativeWrapper</code> objects have the same lifetime as the object they're wrapping.
</p>
<h3 name="Accessing_unsafe_properties"> Accessing unsafe properties </h3>
<p>If unsafe access to a property is required for some reason, this can be accomplished via the <code>wrappedJSObject</code> property of the wrapper.  For example, if <code>docWrapper</code> is a wrapper for <code>doc</code>, then
</p>
<pre class="eval">docWrapper.wrappedJSObject.prop
</pre>
<p>is the same as
</p>
<pre class="eval">doc.prop
</pre>
<h3 name="Limitations_of_XPCNativeWrapper"> Limitations of <code>XPCNativeWrapper</code> </h3>
<p>There are some commonly used properties and coding styles that cannot be used with <code>XPCNativeWrapper</code>.  Specifically:
</p>
<ol><li> Assigning to or reading an <code>on*</code> property on an <code>XPCNativeWrapper</code> of a DOM node or Window object will throw an exception.
</li><li> Access to frames by window name (e.g. <code>window.frameName</code>) does not work on an <code>XPCNativeWrapper</code>
</li><li> <code>document.all</code> does not work on an <code>XPCNativeWrapper</code> for a document.
</li><li> Access to named items by name does not work on an <code>XPCNativeWrapper</code> for an HTML document. For example, if you have a <code>&lt;form name="foo"&gt;</code> and <code>docWrapper</code> is a wrapper for the HTML document <code>doc</code> then <code>doc.foo</code> is an <code>HTMLFormElement</code> while <code>docWrapper.foo</code> is <code>undefined</code>. Code that wishes to do this could use <code>docWrapper.forms{{mediawiki.external('\"foo\"')}}</code> instead.
</li><li> Access to nodes by id doesn't work on an <code>XPCNativeWrapper</code> for an HTML document. <code>getElementById</code> should be used instead.
</li><li> Access to inputs by name doesn't work on an <code>XPCNativeWrapper</code> for an HTML form. Code that wishes to do this should use <code>form.elements{{mediawiki.external('\"inputname\"')}}</code>.
</li><li> Calling methods implemented by NPAPI plugins through the <code>XPCNativeWrapper</code> for the corresponding node does not work.
</li><li> Getting or setting properties implemented by NPAPI plugins though the <code>XPCNativeWrapper</code> for the corresponding node does not work.
</li><li> Calling methods implemented via XBL bindings attached to a node through an <code>XCPNativeWrapper</code> for that node does not work.
</li><li> Getting or setting properties implemented via XBL bindings attached to a node through an <code>XCPNativeWrapper</code> for that node does not work.
</li><li> Enumerating the properties of an <code>XPCNativeWrapper</code> via "<code>for (var p in wrapper)</code>" does not enumerate the IDL-defined properties.
</li><li> Object.prototype is not on the prototype chain of an <code>XPCNativeWrapper</code>.  As a result, various <code>Object.prototype</code> properties are undefined on an <code>XPCNativeWrapper</code> (to be precise, these are <code>__proto__</code>, <code>__parent__</code>, <code>__count__</code>, <code>toSource</code>, <code>toLocaleString</code>, <code>valueOf</code>, <code>watch</code>, <code>unwatch</code>, <code>hasOwnProperty</code>, <code>isPrototypeOf</code>, <code>propertyIsEnumerable</code>, <code>__defineGetter__</code>, <code>__defineSetter__</code>, <code>__lookupGetter__</code>, and <code>__lookupSetter__</code>).
</li><li> There is no support for the <code>importXPCNative</code> method the old <code>XPCNativeWrapper</code> implementation used to have.
</li></ol>
Revert to this revision