Allow autotest to inspect an notification of Chrome
TEST=See correct notification info returned in the new autotest
BUG=b:27850100
Change-Id: I5dda8386358d703547bbf09a2fe8361952156244
Reviewed-on: https://chromium-review.googlesource.com/337951
Commit-Ready: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: Victor Hsieh <victorhsieh@chromium.org>
Reviewed-by: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
diff --git a/client/common_lib/cros/chrome.py b/client/common_lib/cros/chrome.py
index 488aba5..24343fb 100644
--- a/client/common_lib/cros/chrome.py
+++ b/client/common_lib/cros/chrome.py
@@ -189,6 +189,27 @@
return ext.EvaluateJavaScript('window.__login_status')
+ def get_visible_notifications(self):
+ """Returns an array of visible notifications of Chrome.
+
+ For specific type of each notification, please refer to Chromium's
+ chrome/common/extensions/api/autotest_private.idl.
+ """
+ ext = self.autotest_ext
+ if not ext:
+ return None
+
+ ext.ExecuteJavaScript('''
+ window.__items = null;
+ chrome.autotestPrivate.getVisibleNotifications(function(items) {
+ window.__items = items;
+ });
+ ''')
+ if ext.EvaluateJavaScript('window.__items') is None:
+ return None
+ return ext.EvaluateJavaScript('window.__items')
+
+
@property
def browser_type(self):
"""Returns the browser_type."""