Bug 1137591 part 2. Throw if someone does Cu.importGlobalProperties in a Window scope. r=bholley

This commit is contained in:
Boris Zbarsky 2015-03-03 21:01:58 -05:00
parent 84cb117bc7
commit b3a7aa44f6
6 changed files with 11 additions and 6 deletions

View File

@ -17,7 +17,6 @@
const { 'utils': Cu } = Components;
Cu.import("resource://gre/modules/ContactDB.jsm", window);
Cu.importGlobalProperties(["indexedDB"]);
let contactsDB = new ContactDB();
contactsDB.init();

View File

@ -142,7 +142,6 @@
const { 'utils': Cu } = Components;
Cu.import("resource://gre/modules/ContactDB.jsm", window);
Cu.importGlobalProperties(["indexedDB"]);
let cdb = new ContactDB();
cdb.init();

View File

@ -10,8 +10,6 @@ let testGenerator = testSteps();
if (!window.runTest) {
window.runTest = function()
{
Cu.importGlobalProperties(["indexedDB"]);
SimpleTest.waitForExplicitFinish();
testGenerator.next();

View File

@ -25,6 +25,7 @@
#include "mozilla/dom/DOMExceptionBinding.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/WindowBinding.h"
#include "nsZipArchive.h"
#include "nsIDOMFile.h"
#include "nsIDOMFileList.h"
@ -2719,6 +2720,13 @@ nsXPCComponents_Utils::ImportGlobalProperties(HandleValue aPropertyList,
{
RootedObject global(cx, CurrentGlobalOrNull(cx));
MOZ_ASSERT(global);
// Don't allow doing this if the global is a Window
nsGlobalWindow* win;
if (NS_SUCCEEDED(UNWRAP_OBJECT(Window, global, win))) {
return NS_ERROR_NOT_AVAILABLE;
}
GlobalProperties options;
NS_ENSURE_TRUE(aPropertyList.isObject(), NS_ERROR_INVALID_ARG);
RootedObject propertyList(cx, &aPropertyList.toObject());

View File

@ -19,7 +19,9 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.importGlobalProperties(["File"]);
if (!this.File) {
Cu.importGlobalProperties(["File"]);
}
// Allow stuff from this scope to be accessed from non-privileged scopes. This
// would crash if used outside of automation.

View File

@ -15,7 +15,6 @@ Cu.import("resource://gre/modules/devtools/Loader.jsm");
const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
const {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
Cu.importGlobalProperties(['CSS']);
window.onload = function() {
SimpleTest.waitForExplicitFinish();