Bug 1389868: Create bootstrap Sandboxes without indexedDB constructor by default. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 12 Aug 2017 18:33:35 -0700
changeset 645495 b429f99c139ca034e5c93912a81ff7796d8de764
parent 645494 d0678b3872baead9f39aac0d5e7af455beaa4029
child 725909 7b7d4f74c624f15e0ebf16d0ddb77e256663c1f1
push id73767
push usermaglione.k@gmail.com
push dateSun, 13 Aug 2017 01:33:54 +0000
reviewersaswan
bugs1389868
milestone57.0a1
Bug 1389868: Create bootstrap Sandboxes without indexedDB constructor by default. r?aswan MozReview-Commit-ID: EOmdCgta81A
dom/indexedDB/moz.build
dom/indexedDB/test/chrome.ini
dom/indexedDB/test/extensions/bootstrap.js
dom/indexedDB/test/extensions/indexedDB-test@mozilla.org.xpi
dom/indexedDB/test/extensions/install.rdf
dom/indexedDB/test/extensions/moz.build
dom/indexedDB/test/test_globalObjects_other.xul
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/dom/indexedDB/moz.build
+++ b/dom/indexedDB/moz.build
@@ -2,18 +2,16 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "DOM: IndexedDB")
 
-TEST_DIRS += ['test/extensions']
-
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 
 XPCSHELL_TESTS_MANIFESTS += [
     'test/unit/xpcshell-child-process.ini',
--- a/dom/indexedDB/test/chrome.ini
+++ b/dom/indexedDB/test/chrome.ini
@@ -1,5 +1,4 @@
 [DEFAULT]
 support-files = chromeHelpers.js
 
 [test_globalObjects_chrome.xul]
-[test_globalObjects_other.xul]
deleted file mode 100644
--- a/dom/indexedDB/test/extensions/bootstrap.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-function testForExpectedSymbols(stage, data) {
-  const expectedSymbols = [ "IDBKeyRange", "indexedDB" ];
-  for (var symbol of expectedSymbols) {
-    Services.prefs.setBoolPref("indexeddbtest.bootstrap." + stage + "." +
-                               symbol, symbol in this);
-  }
-}
-
-function GlobalObjectsComponent() {
-  this.wrappedJSObject = this;
-}
-
-GlobalObjectsComponent.prototype =
-{
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
-
-  runTest() {
-    const name = "Splendid Test";
-
-    let ok = this.ok;
-    let finishTest = this.finishTest;
-
-    let keyRange = IDBKeyRange.only(42);
-    ok(keyRange, "Got keyRange");
-
-    let request = indexedDB.open(name, 1);
-    request.onerror = function(event) {
-      ok(false, "indexedDB error, '" + event.target.error.name + "'");
-      finishTest();
-    }
-    request.onsuccess = function(event) {
-      let db = event.target.result;
-      ok(db, "Got database");
-      finishTest();
-    }
-  }
-};
-
-var gFactory = {
-  register() {
-    var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-
-    var classID = Components.ID("{d6f85dcb-537d-447e-b783-75d4b405622d}");
-    var description = "IndexedDBTest";
-    var contractID = "@mozilla.org/dom/indexeddb/GlobalObjectsComponent;1";
-    var factory = XPCOMUtils._getFactory(GlobalObjectsComponent);
-
-    registrar.registerFactory(classID, description, contractID, factory);
-
-    this.unregister = function() {
-      registrar.unregisterFactory(classID, factory);
-      delete this.unregister;
-    };
-  }
-};
-
-function install(data, reason) {
-  testForExpectedSymbols("install");
-}
-
-function startup(data, reason) {
-  testForExpectedSymbols("startup");
-  gFactory.register();
-}
-
-function shutdown(data, reason) {
-  testForExpectedSymbols("shutdown");
-  gFactory.unregister();
-}
-
-function uninstall(data, reason) {
-  testForExpectedSymbols("uninstall");
-}
deleted file mode 100644
index bbe2430e261f95e33adc1b970b2a6e53db627bfd..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/dom/indexedDB/test/extensions/install.rdf
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:name>IndexedDBTest</em:name>
-    <em:description>IndexedDB functions for use in testing.</em:description>
-    <em:creator>Mozilla</em:creator>
-    <em:version>2016.03.09</em:version>
-    <em:id>indexedDB-test@mozilla.org</em:id>
-    <em:type>2</em:type>
-    <em:bootstrap>true</em:bootstrap>
-    <em:targetApplication>
-      <Description>
-        <!-- Firefox -->
-        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-        <em:minVersion>45.0</em:minVersion>
-        <em:maxVersion>*</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-    <em:targetApplication>
-      <Description>
-        <!-- Fennec -->
-        <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
-        <em:minVersion>45.0</em:minVersion>
-        <em:maxVersion>*</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-  </Description>
-</RDF>
deleted file mode 100644
--- a/dom/indexedDB/test/extensions/moz.build
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-XPI_NAME = 'indexedDB'
-
-FINAL_TARGET_FILES += [
-    'bootstrap.js',
-    'install.rdf',
-]
-
-TEST_HARNESS_FILES.testing.mochitest.extensions += [
-    'indexedDB-test@mozilla.org.xpi',
-]
deleted file mode 100644
--- a/dom/indexedDB/test/test_globalObjects_other.xul
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<window title="Mozilla Bug 832883"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="runTest();">
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-
-  <script type="application/javascript">
-  <![CDATA[
-  function* testSteps() {
-    // Test for IDBKeyRange and indexedDB availability in bootstrap files.
-    let test = Cc["@mozilla.org/dom/indexeddb/GlobalObjectsComponent;1"].
-               createInstance(Ci.nsISupports).wrappedJSObject;
-    test.ok = ok;
-    test.finishTest = continueToNextStep;
-    test.runTest();
-    yield undefined;
-
-    Cu.import("resource://gre/modules/AddonManager.jsm");
-    AddonManager.getAddonByID("indexedDB-test@mozilla.org",
-                              grabEventAndContinueHandler);
-    let addon = yield undefined;
-    addon.uninstall();
-
-    Cu.import("resource://gre/modules/Services.jsm");
-    for (var stage of [ "install", "startup", "shutdown", "uninstall" ]) {
-      for (var symbol of [ "IDBKeyRange", "indexedDB" ]) {
-        let pref = Services.prefs.getBoolPref("indexeddbtest.bootstrap." + stage +
-                                              "." + symbol, false);
-        ok(pref, "Symbol '" + symbol + "' present during '" + stage + "'");
-      }
-    }
-
-    finishTest();
-    yield undefined;
-  }
-
-  window.runTest = function() {
-    SimpleTest.waitForExplicitFinish();
-
-    testGenerator.next();
-  }
-  ]]>
-  </script>
-
-  <script type="text/javascript" src="chromeHelpers.js"></script>
-
-  <body xmlns="http://www.w3.org/1999/xhtml">
-  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=832883"
-     target="_blank">Mozilla Bug 832883</a>
-  </body>
-</window>
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -4206,17 +4206,16 @@ this.XPIProvider = {
         getService(Ci.nsIAddonInterposition);
       Cu.setAddonInterposition(aId, interposition);
       Cu.allowCPOWsInAddon(aId, true);
     }
 
     if (!aFile.exists()) {
       activeAddon.bootstrapScope =
         new Cu.Sandbox(principal, { sandboxName: aFile.path,
-                                    wantGlobalProperties: ["indexedDB"],
                                     addonId: aId,
                                     metadata: { addonID: aId } });
       logger.error("Attempted to load bootstrap scope from missing directory " + aFile.path);
       return;
     }
 
     if (isWebExtension(aType)) {
       activeAddon.bootstrapScope = Extension.getBootstrapScope(aId, aFile);
@@ -4224,17 +4223,16 @@ this.XPIProvider = {
       let uri = getURIForResourceInFile(aFile, "bootstrap.js").spec;
       if (aType == "dictionary")
         uri = "resource://gre/modules/addons/SpellCheckDictionaryBootstrap.js"
       else if (aType == "apiextension")
         uri = "resource://gre/modules/addons/APIExtensionBootstrap.js"
 
       activeAddon.bootstrapScope =
         new Cu.Sandbox(principal, { sandboxName: uri,
-                                    wantGlobalProperties: ["indexedDB"],
                                     addonId: aId,
                                     metadata: { addonID: aId, URI: uri } });
 
       try {
         // Copy the reason values from the global object into the bootstrap scope.
         for (let name in BOOTSTRAP_REASONS)
           activeAddon.bootstrapScope[name] = BOOTSTRAP_REASONS[name];