When privileged JavaScript in Gecko accesses objects belonging to less-privileged code (such as untrusted web content), it does so, by default, with "Xray vision": a mechanism that filters out certain changes to the objects that could cause them to behave in unexpected ways. For example, privileged code using an Xray to a DOM object sees only  the original, native version of the DOM object. Any expando properties are not visible, and if any native properties have been redefined, this has no effect.

Use this function to determine whether a given object is an Xray or not.


boolean Components.utils.isXrayWrapper(obj);


The object to check.


true if the object is an Xray: false otherwise.


var isXray = Components.utils.isXrayWrapper(gBrowser.contentWindow);       // true
var waived = Components.utils.waiveXrays(gBrowser.contentWindow);
isXray = Components.utils.isXrayWrapper(waived);                       // false

See also