Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6525)

Unified Diff: chrome/test/data/webui/inspect_ui_test.js

Issue 208013003: DevTools: Create end-to-end test for chrome://inspect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed extension test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/inspect_ui_test.js
diff --git a/chrome/test/data/webui/inspect_ui_test.js b/chrome/test/data/webui/inspect_ui_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b7d92748f01374feb9d3fd012c66bcb84616fc4
--- /dev/null
+++ b/chrome/test/data/webui/inspect_ui_test.js
@@ -0,0 +1,75 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function waitForElements(selector, populateFunctionName, callback) {
+ var elements = document.querySelectorAll(selector);
+ if (elements.length) {
+ callback(elements);
+ return;
+ }
+ var originalFunction = window[populateFunctionName];
+ expectNotEquals(undefined, originalFunction);
+ expectEquals(undefined, originalFunction.__isSniffer);
+ var interceptFunction = function() {
+ originalFunction.apply(window, arguments);
+ var elements = document.querySelectorAll(selector);
+ if (elements.length) {
+ window[populateFunctionName] = originalFunction;
+ callback(elements);
+ }
+ };
+ interceptFunction.__isSniffer = true;
+ window[populateFunctionName] = interceptFunction;
+}
+
+function findByContentSubstring(elements, content, childSelector) {
+ return Array.prototype.filter.call(elements, function(element) {
+ if (childSelector)
+ element = element.querySelector(childSelector);
+ return element && element.textContent.indexOf(content) >= 0;
+ })[0];
+}
+
+function testTargetListed(sectionSelector, populateFunctionName, url) {
+ waitForElements(
+ sectionSelector + ' .row',
+ populateFunctionName,
+ function(elements) {
+ var urlElement = findByContentSubstring(elements, url, '.url');
+ expectNotEquals(undefined, urlElement);
+ testDone();
+ });
+}
+
+function testAdbTargetsListed() {
+ waitForElements('.device', 'populateRemoteTargets', function(devices) {
+ expectEquals(2, devices.length);
+
+ var offlineDevice = findByContentSubstring(
+ devices, 'Offline', '.device-name');
+ expectNotEquals(undefined, offlineDevice);
+
+ var onlineDevice = findByContentSubstring(
+ devices, 'Nexus 6', '.device-name');
+ expectNotEquals(undefined, onlineDevice);
+
+ var browsers = onlineDevice.querySelectorAll('.browser');
+ expectEquals(4, browsers.length);
+
+ var chromeBrowser = findByContentSubstring(
+ browsers, 'Chrome (32.0.1679.0)', '.browser-name');
+ expectNotEquals(undefined, chromeBrowser);
+
+ var chromePages = chromeBrowser.querySelectorAll('.pages');
+ var chromiumPage = findByContentSubstring(
+ chromePages, 'http://www.chromium.org/', '.url');
+ expectNotEquals(undefined, chromiumPage);
+
+ var webView = findByContentSubstring(
+ browsers, 'WebView in com.sample.feed (4.0)', '.browser-name');
+ expectNotEquals(undefined, webView);
+
+ testDone();
+ });
+}
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698