Bug 1423843 - Enabled ESLint for dom/notification/test/unit r=Standard8,mccr8
authordivyansh <sharma.divyansh.501@iitg.ernet.in>
Tue, 09 Oct 2018 18:23:15 +0000
changeset 488728 dd0480856174ebb56abe03c063f4833f8c4f5d43
parent 488727 bffefd408262494b20da159ba013f64321254beb
child 488729 f14e8d450327540915e5d28c26a0edb40fcc8a9c
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersStandard8, mccr8
bugs1423843
milestone64.0a1
Bug 1423843 - Enabled ESLint for dom/notification/test/unit r=Standard8,mccr8 Differential Revision: https://phabricator.services.mozilla.com/D8026
.eslintignore
dom/notification/test/unit/common_test_notificationdb.js
dom/notification/test/unit/head_notificationdb.js
dom/notification/test/unit/test_notificationdb.js
dom/notification/test/unit/test_notificationdb_bug1024090.js
dom/notification/test/unit/xpcshell.ini
--- a/.eslintignore
+++ b/.eslintignore
@@ -207,17 +207,16 @@ dom/media/test/**
 dom/media/tests/**
 dom/media/webaudio/**
 dom/media/webspeech/**
 dom/messagechannel/**
 dom/midi/**
 dom/network/**
 dom/notification/Notification*.*
 dom/notification/test/browser/**
-dom/notification/test/unit/**
 dom/notification/test/mochitest/**
 dom/offline/**
 dom/payments/**
 dom/performance/**
 dom/permission/**
 dom/plugins/test/mochitest/**
 dom/plugins/test/unit/**
 dom/power/**
rename from dom/notification/test/unit/common_test_notificationdb.js
rename to dom/notification/test/unit/head_notificationdb.js
--- a/dom/notification/test/unit/common_test_notificationdb.js
+++ b/dom/notification/test/unit/head_notificationdb.js
@@ -1,17 +1,17 @@
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function getNotificationObject(app, id, tag) {
   return {
     origin: "https://" + app + ".gaiamobile.org/",
-    id: id,
+    id,
     title: app + "Notification:" + Date.now(),
     dir: "auto",
     lang: "",
     body: app + " notification body",
     tag: tag || "",
     icon: "icon.png"
   };
 }
@@ -25,17 +25,17 @@ var calendarNotification =
 // Helper to start the NotificationDB
 function startNotificationDB() {
   ChromeUtils.import("resource://gre/modules/NotificationDB.jsm");
 }
 
 // Helper function to add a listener, send message and treat the reply
 function addAndSend(msg, reply, callback, payload, runNext = true) {
   let handler = {
-    receiveMessage: function(message) {
+    receiveMessage(message) {
       if (message.name === reply) {
         Services.cpmm.removeMessageListener(reply, handler);
         callback(message);
         if (runNext) {
           run_next_test();
         }
       }
     }
--- a/dom/notification/test/unit/test_notificationdb.js
+++ b/dom/notification/test/unit/test_notificationdb.js
@@ -12,94 +12,94 @@ add_test(function test_get_none() {
   let msgReply = "Notification:GetAll:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
     Assert.equal(0, message.data.notifications.length);
   };
 
   addAndSend("Notification:GetAll", msgReply, msgHandler, {
     origin: systemNotification.origin,
-    requestID: requestID
+    requestID
   });
 });
 
 // Store one notification
 add_test(function test_send_one() {
   let requestID = 1;
   let msgReply = "Notification:Save:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Save", msgReply, msgHandler, {
     origin: systemNotification.origin,
     notification: systemNotification,
-    requestID: requestID
+    requestID
   });
 });
 
 // Get one notification, one exists
 add_test(function test_get_one() {
   let requestID = 2;
   let msgReply = "Notification:GetAll:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
     Assert.equal(1, message.data.notifications.length);
     // compare the content
     compareNotification(systemNotification, message.data.notifications[0]);
   };
 
   addAndSend("Notification:GetAll", msgReply, msgHandler, {
     origin: systemNotification.origin,
-    requestID: requestID
+    requestID
   });
 });
 
 // Delete one notification
 add_test(function test_delete_one() {
   let requestID = 3;
   let msgReply = "Notification:Delete:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Delete", msgReply, msgHandler, {
     origin: systemNotification.origin,
     id: systemNotification.id,
-    requestID: requestID
+    requestID
   });
 });
 
 // Get one notification, none exists
 add_test(function test_get_none_again() {
   let requestID = 4;
   let msgReply = "Notification:GetAll:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
     Assert.equal(0, message.data.notifications.length);
   };
 
   addAndSend("Notification:GetAll", msgReply, msgHandler, {
     origin: systemNotification.origin,
-    requestID: requestID
+    requestID
   });
 });
 
 // Delete one notification that do not exists anymore
 add_test(function test_delete_one_nonexistent() {
   let requestID = 5;
   let msgReply = "Notification:Delete:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Delete", msgReply, msgHandler, {
     origin: systemNotification.origin,
     id: systemNotification.id,
-    requestID: requestID
+    requestID
   });
 });
 
 // Store two notifications with the same id
 add_test(function test_send_two_get_one() {
   let requestID = 6;
   let calls = 0;
 
@@ -120,17 +120,17 @@ add_test(function test_send_two_get_one(
         requestID: (requestID + 2)
       });
     }
   };
 
   addAndSend("Notification:Save", msgSaveReply, msgSaveHandler, {
     origin: systemNotification.origin,
     notification: systemNotification,
-    requestID: requestID
+    requestID
   }, false);
 
   addAndSend("Notification:Save", msgSaveReply, msgSaveHandler, {
     origin: systemNotification.origin,
     notification: systemNotification,
     requestID: (requestID + 1)
   }, false);
 });
@@ -141,33 +141,33 @@ add_test(function test_delete_previous()
   let msgReply = "Notification:Delete:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Delete", msgReply, msgHandler, {
     origin: systemNotification.origin,
     id: systemNotification.id,
-    requestID: requestID
+    requestID
   });
 });
 
 // Store two notifications from same origin with the same tag
 add_test(function test_send_two_get_one() {
   let requestID = 10;
   let tag = "voicemail";
 
   let systemNotification1 =
     getNotificationObject("system", "{f271f9ee-3955-4c10-b1f2-af552fb270ee}", tag);
   let systemNotification2 =
     getNotificationObject("system", "{8ef9a628-f0f4-44b4-820d-c117573c33e3}", tag);
 
   let msgGetReply = "Notification:GetAll:Return:OK";
   let msgGetNotifHandler = {
-    receiveMessage: function(message) {
+    receiveMessage(message) {
       if (message.name === msgGetReply) {
         Services.cpmm.removeMessageListener(msgGetReply, msgGetNotifHandler);
         let notifications = message.data.notifications;
         // same tag, so replaced
         Assert.equal(1, notifications.length);
         // compare the content
         compareNotification(systemNotification2, notifications[0]);
         run_next_test();
@@ -188,17 +188,17 @@ add_test(function test_send_two_get_one(
         requestID: message.data.requestID + 2 // 12, 13
       });
     }
   };
 
   addAndSend("Notification:Save", msgSaveReply, msgSaveHandler, {
     origin: systemNotification1.origin,
     notification: systemNotification1,
-    requestID: requestID // 10
+    requestID // 10
   }, false);
 
   addAndSend("Notification:Save", msgSaveReply, msgSaveHandler, {
     origin: systemNotification2.origin,
     notification: systemNotification2,
     requestID: (requestID + 1) // 11
   }, false);
 });
@@ -209,17 +209,17 @@ add_test(function test_delete_previous()
   let msgReply = "Notification:Delete:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Delete", msgReply, msgHandler, {
     origin: systemNotification.origin,
     id: "{8ef9a628-f0f4-44b4-820d-c117573c33e3}",
-    requestID: requestID
+    requestID
   });
 });
 
 // Store two notifications from two origins with the same tag
 add_test(function test_send_two_get_two() {
   let requestID = 20;
   let tag = "voicemail";
 
@@ -227,17 +227,17 @@ add_test(function test_send_two_get_two(
   systemNotification1.tag = tag;
 
   let calendarNotification2 = calendarNotification;
   calendarNotification2.tag = tag;
 
   let msgGetReply = "Notification:GetAll:Return:OK";
   let msgGetCalls = 0;
   let msgGetHandler = {
-    receiveMessage: function(message) {
+    receiveMessage(message) {
       if (message.name === msgGetReply) {
         msgGetCalls++;
         let notifications = message.data.notifications;
 
         // one notification per origin
         Assert.equal(1, notifications.length);
 
         // first call should be system notification
@@ -254,17 +254,17 @@ add_test(function test_send_two_get_two(
       }
     }
   };
   Services.cpmm.addMessageListener(msgGetReply, msgGetHandler);
 
   let msgSaveReply = "Notification:Save:Return:OK";
   let msgSaveCalls = 0;
   let msgSaveHandler = {
-    receiveMessage: function(message) {
+    receiveMessage(message) {
       if (message.name === msgSaveReply) {
         msgSaveCalls++;
         if (msgSaveCalls === 2) {
           Services.cpmm.removeMessageListener(msgSaveReply, msgSaveHandler);
 
           // Trigger getall for each origin
           Services.cpmm.sendAsyncMessage("Notification:GetAll", {
             origin: systemNotification1.origin,
@@ -279,17 +279,17 @@ add_test(function test_send_two_get_two(
       }
     }
   };
   Services.cpmm.addMessageListener(msgSaveReply, msgSaveHandler);
 
   Services.cpmm.sendAsyncMessage("Notification:Save", {
     origin: systemNotification1.origin,
     notification: systemNotification1,
-    requestID: requestID // 20
+    requestID // 20
   });
 
   Services.cpmm.sendAsyncMessage("Notification:Save", {
     origin: calendarNotification2.origin,
     notification: calendarNotification2,
     requestID: (requestID + 1) // 21
   });
 });
@@ -300,11 +300,11 @@ add_test(function test_delete_previous()
   let msgReply = "Notification:Delete:Return:OK";
   let msgHandler = function(message) {
     Assert.equal(requestID, message.data.requestID);
   };
 
   addAndSend("Notification:Delete", msgReply, msgHandler, {
     origin: systemNotification.origin,
     id: "{2bc883bf-2809-4432-b0f4-f54e10372764}",
-    requestID: requestID
+    requestID
   });
 });
--- a/dom/notification/test/unit/test_notificationdb_bug1024090.js
+++ b/dom/notification/test/unit/test_notificationdb_bug1024090.js
@@ -1,16 +1,16 @@
 "use strict";
 
 function run_test() {
   do_get_profile();
   run_next_test();
 }
 
-/// For bug 1024090: test edge case of notificationstore.json
+// For bug 1024090: test edge case of notificationstore.json
 add_test(function test_bug1024090_purge() {
   ChromeUtils.import("resource://gre/modules/osfile.jsm");
   const NOTIFICATION_STORE_PATH =
     OS.Path.join(OS.Constants.Path.profileDir, "notificationstore.json");
   let cleanup = OS.File.writeAtomic(NOTIFICATION_STORE_PATH, "");
   cleanup.then(
     function onSuccess() {
       ok(true, "Notification database cleaned.");
@@ -31,26 +31,26 @@ add_test(function test_bug1024090_send_o
   let msgReply = "Notification:Save:Return:OK";
   let msgHandler = function(message) {
     equal(requestID, message.data.requestID, "Checking requestID");
   };
 
   addAndSend("Notification:Save", msgReply, msgHandler, {
     origin: systemNotification.origin,
     notification: systemNotification,
-    requestID: requestID
+    requestID
   });
 });
 
 // Get one notification, one exists
 add_test(function test_bug1024090_get_one() {
   let requestID = 2;
   let msgReply = "Notification:GetAll:Return:OK";
   let msgHandler = function(message) {
     equal(requestID, message.data.requestID, "Checking requestID");
     equal(1, message.data.notifications.length, "One notification stored");
   };
 
   addAndSend("Notification:GetAll", msgReply, msgHandler, {
     origin: systemNotification.origin,
-    requestID: requestID
+    requestID
   });
 });
--- a/dom/notification/test/unit/xpcshell.ini
+++ b/dom/notification/test/unit/xpcshell.ini
@@ -1,6 +1,6 @@
 [DEFAULT]
-head = common_test_notificationdb.js
+head = head_notificationdb.js
 skip-if = toolkit == 'android'
 
 [test_notificationdb.js]
 [test_notificationdb_bug1024090.js]