Bug 1264106 - Fix browser_ConsoleAPI_originAttributes.js permafail on DevEdition. r?baku draft
authorLuca Greco <lgreco@mozilla.com>
Wed, 13 Apr 2016 00:48:01 +0200
changeset 350199 b867ee8e1b78a28e63d738720b823f44053106e2
parent 349543 039b504d1161b427ab475451bc805da8cd014b4c
child 518267 2caac76543fb67744f3033667dd349e148744178
push id15267
push userluca.greco@alcacoop.it
push dateTue, 12 Apr 2016 23:23:31 +0000
reviewersbaku
bugs1264106
milestone48.0a1
Bug 1264106 - Fix browser_ConsoleAPI_originAttributes.js permafail on DevEdition. r?baku - the test case was failing because of an additional error message which is logged only on DevEdition. - this patch makes the assertions on the cached messages more resilient to this kind of changes in the logged messages, by filtering the cached messages and then making assertions on the length of the messages found. MozReview-Commit-ID: GIPOkWzM9Bo
dom/tests/browser/browser_ConsoleAPI_originAttributes.js
--- a/dom/tests/browser/browser_ConsoleAPI_originAttributes.js
+++ b/dom/tests/browser/browser_ConsoleAPI_originAttributes.js
@@ -24,23 +24,23 @@ const ConsoleObserver = {
 
       is(consoleAPIMessage.arguments[0], EXPECTED_CONSOLE_MESSAGE_CONTENT,
          "the consoleAPIMessage contains the expected message");
 
       ok(consoleAPIMessage.originAttributes, "the consoleAPImessage contains originattributes");
       is(consoleAPIMessage.originAttributes.addonId, FAKE_ADDON_ID,
          "the consoleAPImessage's originAttributes contains the expected addonId");
 
-      let cachedMessages = ConsoleAPIStorage.getEvents();
-
-      is(cachedMessages.length, 1, "found one console api messsage as expected");
+      let cachedMessages = ConsoleAPIStorage.getEvents().filter((msg) => {
+        return msg.originAttributes && msg.originAttributes.addonId == FAKE_ADDON_ID;
+      });
 
-      ok(cachedMessages[0].originAttributes, "the consoleAPImessage contains originattributes");
-      is(cachedMessages[0].originAttributes.addonId, FAKE_ADDON_ID,
-         "the consoleAPImessage's originAttributes contains the expected addonId");
+      is(cachedMessages.length, 1, "found the expected cached console messages from the addon");
+      is(cachedMessages[0] && cachedMessages[0].originAttributes.addonId, FAKE_ADDON_ID,
+         "the cached message's originAttributes contains the expected addonId");
 
       finish();
     }
   }
 };
 
 function test()
 {