Bug 1502646 - Enable using ChromeUtils in Robocop JS tests. r=gbrown

We finally updated our host utils at some point after bug 1431533, so this
works now.

robocop_head.js is being included as a normal page <script> as well, though, and
as such is left to bug 1502674.

Differential Revision: https://phabricator.services.mozilla.com/D10278

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2018-10-30 20:36:10 +00:00
Родитель 83fc24bb27
Коммит 77c9e65708
19 изменённых файлов: 36 добавлений и 85 удалений

Просмотреть файл

@ -1,8 +0,0 @@
"use strict";
module.exports = {
"rules": {
"mozilla/use-chromeutils-generateqi": 0,
},
};

Просмотреть файл

@ -27,6 +27,7 @@
/* eslint-disable mozilla/use-cc-etc */
/* eslint-disable mozilla/use-chromeutils-import */
/* eslint-disable mozilla/use-chromeutils-generateqi */
/* eslint-disable mozilla/use-services */
var _quit = false;

Просмотреть файл

@ -56,7 +56,9 @@ function testOneFile(uri) {
let principal = SpecialPowers.Cc["@mozilla.org/systemprincipal;1"]
.createInstance(SpecialPowers.Ci.nsIPrincipal);
let testScope = SpecialPowers.Cu.Sandbox(principal);
let testScope =
SpecialPowers.Cu.Sandbox(principal, { sandboxName: uri,
wantGlobalProperties: ["ChromeUtils"] });
// Populate test environment with test harness prerequisites.
testScope.Components = SpecialPowers.Components;

Просмотреть файл

@ -4,11 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/Geometry.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Geometry.jsm");
const ACCESSIBLECARET_PREF = "layout.accessiblecaret.enabled";
const BASE_TEST_URL = "http://mochi.test:8888/tests/robocop/testAccessibleCarets.html";
@ -46,10 +44,8 @@ function do_promiseTabChangeEvent(tabId, eventType) {
* or if we have basic content.
*/
function isInputOrTextarea(element) {
// ChromeUtils isn't included in robocop tests, so we have to use a different
// way to test elements.
return (element.namespaceURI === "http://www.w3.org/1999/xhtml" &&
(element.localName === "input" || element.localName === "textarea"));
return (ChromeUtils.getClassName(element) === "HTMLInputElement" ||
ChromeUtils.getClassName(element) === "HTMLTextAreaElement");
}
/**

Просмотреть файл

@ -2,10 +2,8 @@
* 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/. */
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
let java = new JavaBridge(this);
do_register_cleanup(() => {

Просмотреть файл

@ -8,12 +8,7 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {ChromeUtils} = Cu.getGlobalForObject(XPCOMUtils);
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
// event name
const TOPIC_ANDROID_CAST_DEVICE_ADDED = "AndroidCastDevice:Added";

Просмотреть файл

@ -5,9 +5,7 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
// We use a global variable to track the <browser> where the tests are happening
var browser;

Просмотреть файл

@ -1,7 +1,5 @@
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
var java = new JavaBridge(this);

Просмотреть файл

@ -5,9 +5,7 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
add_test(function filepicker_open() {
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");

Просмотреть файл

@ -5,10 +5,8 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Messaging.jsm");
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
const TEST_URL = "http://mochi.test:8888/tests/robocop/robocop_text_page.html";

Просмотреть файл

@ -5,10 +5,8 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
// Make the timer global so it doesn't get GC'd
var gTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);

Просмотреть файл

@ -4,9 +4,7 @@
* 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/. */
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/ReaderMode.jsm");
ChromeUtils.import("resource://gre/modules/ReaderMode.jsm");
var java = new JavaBridge(this);

Просмотреть файл

@ -5,11 +5,9 @@
/* globals ReaderMode */
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/ReaderMode.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
ChromeUtils.import("resource://gre/modules/ReaderMode.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Task.jsm");
var Reader = Services.wm.getMostRecentWindow("navigator:browser").Reader;

Просмотреть файл

@ -3,11 +3,9 @@
* 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/. */
/* eslint-disable mozilla/use-chromeutils-import */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RuntimePermissions", "resource://gre/modules/RuntimePermissions.jsm");
ChromeUtils.defineModuleGetter(this, "RuntimePermissions", "resource://gre/modules/RuntimePermissions.jsm");
add_task(async function test_snackbar_api() {
RuntimePermissions.waitForPermissions([

Просмотреть файл

@ -3,12 +3,8 @@
* 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/. */
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher", "resource://gre/modules/Messaging.jsm");
ChromeUtils.defineModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm");
ChromeUtils.defineModuleGetter(this, "EventDispatcher", "resource://gre/modules/Messaging.jsm");
add_task(async function test_snackbar_api() {
Snackbars.show("This is a Snackbar", Snackbars.LENGTH_INDEFINITE, {

Просмотреть файл

@ -5,11 +5,9 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
function promiseLoadEvent(browser, url, eventType = "load", runBeforeLoad) {
return new Promise((resolve, reject) => {
@ -58,12 +56,7 @@ function doUpdate() {
return new Promise((resolve, reject) => {
let listener = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsIUrlClassifierUpdateObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIUrlClassifierUpdateObserver]),
updateUrlRequested: function(url) { },
streamFinished: function(status) { },
updateError: function(errorCode) {

Просмотреть файл

@ -3,9 +3,7 @@
* 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/. */
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
const EVENT_TEST1 = "_test_event_1.1";
const EVENT_TEST2 = "_test_event_2.1";

Просмотреть файл

@ -1,6 +1,4 @@
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/ClientID.jsm");
ChromeUtils.import("resource://gre/modules/ClientID.jsm");
var java = new JavaBridge(this);
do_register_cleanup(() => {

Просмотреть файл

@ -5,10 +5,8 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-import */
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
Cu.importGlobalProperties(["InspectorUtils"]);