Bug 1389469 - Remove unreferenced SDK modules. r?kmag draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 11 Aug 2017 21:44:09 +0900
changeset 644876 2b7080c61458254e009aeb8cd62a5cb17cde86de
parent 644870 a97564bd2c2e21e63757efc67bbd95f2cbe20905
child 725735 48a1cf4fc0a4556c16f7f39709e141be3120c58a
push id73574
push userVYV03354@nifty.ne.jp
push dateFri, 11 Aug 2017 12:44:55 +0000
reviewerskmag
bugs1389469
milestone57.0a1
Bug 1389469 - Remove unreferenced SDK modules. r?kmag MozReview-Commit-ID: DiJW6bAMZFF
addon-sdk/source/lib/sdk/content/mod.js
addon-sdk/source/lib/sdk/content/utils.js
deleted file mode 100644
--- a/addon-sdk/source/lib/sdk/content/mod.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/* 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/. */
-"use strict";
-
-module.metadata = {
-  "stability": "experimental"
-};
-
-const { Ci } = require("chrome");
-const { dispatcher } = require("../util/dispatcher");
-const { add, remove, iterator } = require("../lang/weak-set");
-
-var getTargetWindow = dispatcher("getTargetWindow");
-
-getTargetWindow.define(function (target) {
-  if (target instanceof Ci.nsIDOMWindow)
-    return target;
-  if (target instanceof Ci.nsIDOMDocument)
-    return target.defaultView || null;
-
-  return null;
-});
-
-exports.getTargetWindow = getTargetWindow;
-
-var attachTo = dispatcher("attachTo");
-exports.attachTo = attachTo;
-
-var detachFrom = dispatcher("detatchFrom");
-exports.detachFrom = detachFrom;
-
-function attach(modification, target) {
-  if (!modification)
-    return;
-
-  let window = getTargetWindow(target);
-
-  attachTo(modification, window);
-
-  // modification are stored per content; `window` reference can still be the
-  // same even if the content is changed, therefore `document` is used instead.
-  add(modification, window.document);
-}
-exports.attach = attach;
-
-function detach(modification, target) {
-  if (!modification)
-    return;
-
-  if (target) {
-    let window = getTargetWindow(target);
-    detachFrom(modification, window);
-    remove(modification, window.document);
-  }
-  else {
-    let documents = iterator(modification);
-    for (let document of documents) {
-      let window = document.defaultView;
-      // The window might have already gone away
-      if (!window)
-        continue;
-      detachFrom(modification, document.defaultView);
-      remove(modification, document);
-    }
-  }
-}
-exports.detach = detach;
deleted file mode 100644
--- a/addon-sdk/source/lib/sdk/content/utils.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/* 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/. */
-'use strict';
-
-module.metadata = {
-  'stability': 'unstable'
-};
-
-lazyRequire(this, '../util/object', "merge");
-lazyRequire(this, '../self', "data");
-var assetsURI = data.url();
-var isArray = Array.isArray;
-var method = require('../../method/core');
-lazyRequire(this, '../util/uuid', "uuid");
-
-const isAddonContent = ({ contentURL }) =>
-  contentURL && data.url(contentURL).startsWith(assetsURI);
-
-exports.isAddonContent = isAddonContent;
-
-function hasContentScript({ contentScript, contentScriptFile }) {
-  return (isArray(contentScript) ? contentScript.length > 0 :
-         !!contentScript) ||
-         (isArray(contentScriptFile) ? contentScriptFile.length > 0 :
-         !!contentScriptFile);
-}
-exports.hasContentScript = hasContentScript;
-
-function requiresAddonGlobal(model) {
-  return model.injectInDocument || (isAddonContent(model) && !hasContentScript(model));
-}
-exports.requiresAddonGlobal = requiresAddonGlobal;
-
-function getAttachEventType(model) {
-  if (!model) return null;
-  let when = model.contentScriptWhen;
-  return requiresAddonGlobal(model) ? 'document-element-inserted' :
-         when === 'start' ? 'document-element-inserted' :
-         when === 'ready' ? 'DOMContentLoaded' :
-         when === 'end' ? 'load' :
-         null;
-}
-exports.getAttachEventType = getAttachEventType;
-
-var attach = method('worker-attach');
-exports.attach = attach;
-
-var connect = method('worker-connect');
-exports.connect = connect;
-
-var detach = method('worker-detach');
-exports.detach = detach;
-
-var destroy = method('worker-destroy');
-exports.destroy = destroy;
-
-function WorkerHost (workerFor) {
-  // Define worker properties that just proxy to underlying worker
-  return ['postMessage', 'port', 'url', 'tab'].reduce(function(proto, name) {
-    // Use descriptor properties instead so we can call
-    // the worker function in the context of the worker so we
-    // don't have to create new functions with `fn.bind(worker)`
-    let descriptorProp = {
-      value: function (...args) {
-        let worker = workerFor(this);
-        return worker[name].apply(worker, args);
-      }
-    };
-    
-    let accessorProp = {
-      get: function () { return workerFor(this)[name]; },
-      set: function (value) { workerFor(this)[name] = value; }
-    };
-
-    Object.defineProperty(proto, name, merge({
-      enumerable: true,
-      configurable: false,
-    }, isDescriptor(name) ? descriptorProp : accessorProp));
-    return proto;
-  }, {});
-  
-  function isDescriptor (prop) {
-    return ~['postMessage'].indexOf(prop);
-  }
-}
-exports.WorkerHost = WorkerHost;
-
-function makeChildOptions(options) {
-  function makeStringArray(arrayOrValue) {
-    if (!arrayOrValue)
-      return [];
-    return [].concat(arrayOrValue).map(String);
-  }
-
-  return {
-    id: String(uuid()),
-    contentScript: makeStringArray(options.contentScript),
-    contentScriptFile: makeStringArray(options.contentScriptFile),
-    contentScriptOptions: options.contentScriptOptions ?
-                          JSON.stringify(options.contentScriptOptions) :
-                          null,
-  }
-}
-exports.makeChildOptions = makeChildOptions;