forked from mirrors/gecko-dev
Bug 1509042 - Enable Eslint for dom/notification (manual changes) r=Ehsan
Depends on D12815 Differential Revision: https://phabricator.services.mozilla.com/D12816 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ac71873828
commit
e26e5ee5d4
6 changed files with 26 additions and 24 deletions
|
|
@ -189,9 +189,6 @@ dom/media/webspeech/**
|
||||||
dom/messagechannel/**
|
dom/messagechannel/**
|
||||||
dom/midi/**
|
dom/midi/**
|
||||||
dom/network/**
|
dom/network/**
|
||||||
dom/notification/Notification*.*
|
|
||||||
dom/notification/test/browser/**
|
|
||||||
dom/notification/test/mochitest/**
|
|
||||||
dom/payments/**
|
dom/payments/**
|
||||||
dom/performance/**
|
dom/performance/**
|
||||||
dom/permission/**
|
dom/permission/**
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,11 @@ var EXPORTED_SYMBOLS = [];
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
function debug(s) { dump("-*- NotificationDB component: " + s + "\n"); }
|
function debug(s) { dump("-*- NotificationDB component: " + s + "\n"); }
|
||||||
|
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "Services",
|
ChromeUtils.defineModuleGetter(this, "Services",
|
||||||
"resource://gre/modules/Services.jsm");
|
"resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage",
|
|
||||||
"@mozilla.org/notificationStorage;1",
|
|
||||||
"nsINotificationStorage");
|
|
||||||
|
|
||||||
const NOTIFICATION_STORE_DIR = OS.Constants.Path.profileDir;
|
const NOTIFICATION_STORE_DIR = OS.Constants.Path.profileDir;
|
||||||
const NOTIFICATION_STORE_PATH =
|
const NOTIFICATION_STORE_PATH =
|
||||||
OS.Path.join(NOTIFICATION_STORE_DIR, "notificationstore.json");
|
OS.Path.join(NOTIFICATION_STORE_DIR, "notificationstore.json");
|
||||||
|
|
@ -258,15 +253,16 @@ var NotificationDB = {
|
||||||
switch (task.operation) {
|
switch (task.operation) {
|
||||||
case "getall":
|
case "getall":
|
||||||
return this.taskGetAll(task.data);
|
return this.taskGetAll(task.data);
|
||||||
break;
|
|
||||||
|
|
||||||
case "save":
|
case "save":
|
||||||
return this.taskSave(task.data);
|
return this.taskSave(task.data);
|
||||||
break;
|
|
||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
return this.taskDelete(task.data);
|
return this.taskDelete(task.data);
|
||||||
break;
|
|
||||||
|
default:
|
||||||
|
return Promise.reject(
|
||||||
|
new Error(`Found a task with unknown operation ${task.operation}`));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(payload => {
|
.then(payload => {
|
||||||
|
|
@ -279,7 +275,7 @@ var NotificationDB = {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
debug("Error while running " + this.runningTask.operation + ": " + err);
|
debug("Error while running " + this.runningTask.operation + ": " + err);
|
||||||
}
|
}
|
||||||
this.runningTask.defer.reject(new String(err));
|
this.runningTask.defer.reject(err);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.runNextTask();
|
this.runNextTask();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable mozilla/use-chromeutils-generateqi */
|
||||||
var MockServices = (function() {
|
var MockServices = (function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -76,7 +77,13 @@ var MockServices = (function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
QueryInterface: ChromeUtils.generateQI(["nsIAlertsService"]),
|
QueryInterface(aIID) {
|
||||||
|
if (SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsISupports) ||
|
||||||
|
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
throw SpecialPowers.Components.results.NS_ERROR_NO_INTERFACE;
|
||||||
|
},
|
||||||
|
|
||||||
createInstance(aOuter, aIID) {
|
createInstance(aOuter, aIID) {
|
||||||
if (aOuter != null) {
|
if (aOuter != null) {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ var NotificationTest = (function() {
|
||||||
|
|
||||||
(function executeRemainingTests(remainingTests) {
|
(function executeRemainingTests(remainingTests) {
|
||||||
if (!remainingTests.length) {
|
if (!remainingTests.length) {
|
||||||
return callback();
|
callback();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextTest = remainingTests.shift();
|
var nextTest = remainingTests.shift();
|
||||||
|
|
@ -45,7 +46,7 @@ var NotificationTest = (function() {
|
||||||
|
|
||||||
var fakeCustomData = (function() {
|
var fakeCustomData = (function() {
|
||||||
var buffer = new ArrayBuffer(2);
|
var buffer = new ArrayBuffer(2);
|
||||||
var dv = new DataView(buffer).setInt16(0, 42, true);
|
new DataView(buffer).setInt16(0, 42, true);
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = canvas.height = 100;
|
canvas.width = canvas.height = 100;
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Notification Basics</title>
|
<title>Notification Basics</title>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<script type="text/javascript" src="MockServices.js"></script>
|
<script type="text/javascript" src="MockServices.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="text/javascript" src="NotificationTest.js"></script>
|
<script type="text/javascript" src="NotificationTest.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
// Create a new notification to make sure
|
// Create a new notification to make sure
|
||||||
// Notification.get() works while creating
|
// Notification.get() works while creating
|
||||||
var notification = new Notification("this is a test");
|
new Notification("this is a test");
|
||||||
|
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
ok(true, "promise should be fulfilled");
|
ok(true, "promise should be fulfilled");
|
||||||
|
|
@ -55,18 +55,18 @@
|
||||||
promise.then(function(notifications) {
|
promise.then(function(notifications) {
|
||||||
ok(notifications.length, "should return notifications");
|
ok(notifications.length, "should return notifications");
|
||||||
for (var i = 0; i < notifications.length; i++) {
|
for (var i = 0; i < notifications.length; i++) {
|
||||||
var notification = notifications[i];
|
var currentNotification = notifications[i];
|
||||||
if (notification.tag === options.tag) {
|
if (currentNotification.tag === options.tag) {
|
||||||
ok(true, "should contain newly created notification");
|
ok(true, "should contain newly created notification");
|
||||||
for (var key in options) {
|
for (var key in options) {
|
||||||
if (key === "data") {
|
if (key === "data") {
|
||||||
ok(NotificationTest.customDataMatches(notification.data),
|
ok(NotificationTest.customDataMatches(currentNotification.data),
|
||||||
"data property should match");
|
"data property should match");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
is(notification[key], options[key], key + " property should match");
|
is(currentNotification[key], options[key], key + " property should match");
|
||||||
}
|
}
|
||||||
notification.close();
|
currentNotification.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +85,8 @@
|
||||||
promise.then(function(notifications) {
|
promise.then(function(notifications) {
|
||||||
var notification = notifications[0];
|
var notification = notifications[0];
|
||||||
is(notifications.length, 1, "should return 1 notification");
|
is(notifications.length, 1, "should return 1 notification");
|
||||||
is(notifications[0].title, "title3", "titles should match");
|
is(notification.title, "title3", "titles should match");
|
||||||
is(notifications[0].tag, "tag3", "tags should match");
|
is(notification.tag, "tag3", "tags should match");
|
||||||
var closeCount = 0;
|
var closeCount = 0;
|
||||||
var waitForAll = function() {
|
var waitForAll = function() {
|
||||||
if (++closeCount >= 3) {
|
if (++closeCount >= 3) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=782211
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
</pre>
|
</pre>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
/* eslint-disable mozilla/use-chromeutils-generateqi */
|
||||||
const MOCK_CID = SpecialPowers.wrap(SpecialPowers.Components).ID("{dbe37e64-d9a3-402c-8d8a-0826c619f7ad}");
|
const MOCK_CID = SpecialPowers.wrap(SpecialPowers.Components).ID("{dbe37e64-d9a3-402c-8d8a-0826c619f7ad}");
|
||||||
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
|
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue