Bug 790732 - Fix automation detection to handle Components shim. rs=mccr8

This commit is contained in:
Bobby Holley 2013-03-28 14:26:02 -07:00
parent 21a28ed93e
commit 69ef591f26
2 changed files with 11 additions and 2 deletions

View File

@ -10,7 +10,12 @@ var archiveReaderEnabled = false;
// and content mochitests (where the |Components| object is accessible only as
// SpecialPowers.Components). Expose Components if necessary here to make things
// work everywhere.
if (typeof Components === 'undefined' && typeof SpecialPowers === 'object')
//
// Even if the real |Components| doesn't exist, we might shim in a simple JS
// placebo for compat. An easy way to differentiate this from the real thing
// is whether the property is read-only or not.
var c = Object.getOwnPropertyDescriptor(this, 'Components');
if ((!c.value || c.writable) && typeof SpecialPowers === 'object')
Components = SpecialPowers.Components;
function executeSoon(aFun)

View File

@ -20,7 +20,11 @@
// naming collisions with anything that might be defined in the scope that imports
// this script.
window.__defineGetter__('_EU_Ci', function() {
return 'Components' in window ? Components.interfaces : SpecialPowers.Ci;
// Even if the real |Components| doesn't exist, we might shim in a simple JS
// placebo for compat. An easy way to differentiate this from the real thing
// is whether the property is read-only or not.
var c = Object.getOwnPropertyDescriptor(window, 'Components');
return c.value && !c.writable ? Components.interfaces : SpecialPowers.Ci;
});
/**