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

Unified Diff: chrome/test/data/devtools/target_list/background.js

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Rebase Created 7 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/extensions/extension_service.cc ('k') | chrome/test/data/devtools/target_list/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/devtools/target_list/background.js
diff --git a/chrome/test/data/devtools/target_list/background.js b/chrome/test/data/devtools/target_list/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..4fb3d9228eee37620ece92d4acbe7a4d80f74e2e
--- /dev/null
+++ b/chrome/test/data/devtools/target_list/background.js
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 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 requestUrl(url, callback) {
+ var req = new XMLHttpRequest();
+ req.open('GET', url, true);
+ req.onload = function() {
+ if (req.status == 200)
+ callback(req.responseText);
+ else
+ req.onerror();
+ };
+ req.onerror = function() {
+ chrome.test.fail('XHR failed: ' + req.status);
+ };
+ req.send(null);
+}
+
+var REMOTE_DEBUGGER_HOST = 'localhost:9222';
+
+function checkTarget(targets, url, type, opt_title, opt_faviconUrl) {
+ var target =
+ targets.filter(function(t) { return t.url == url }) [0];
+ if (!target)
+ chrome.test.fail('Cannot find a target with url ' + url);
+
+ var wsAddress = REMOTE_DEBUGGER_HOST + '/devtools/page/' + target.id;
+
+ chrome.test.assertEq(
+ '/devtools/devtools.html?ws=' + wsAddress,
+ target.devtoolsFrontendUrl);
+ chrome.test.assertEq(opt_faviconUrl || '', target.faviconUrl);
+ chrome.test.assertEq('/thumb/' + target.id, target.thumbnailUrl);
+ chrome.test.assertEq(opt_title || target.url, target.title);
+ chrome.test.assertEq(type, target.type);
+ chrome.test.assertEq('ws://' + wsAddress, target.webSocketDebuggerUrl);
+}
+
+chrome.test.runTests([
+ function discoverTargets() {
+ var testPageUrl = chrome.extension.getURL('test_page.html');
+
+ function onUpdated() {
+ chrome.tabs.onUpdated.removeListener(onUpdated);
+ requestUrl('http://' + REMOTE_DEBUGGER_HOST + '/json', function(text) {
+ var targets = JSON.parse(text);
+
+ checkTarget(targets, 'about:blank', 'page');
+ checkTarget(targets, testPageUrl, 'page', 'Test page',
+ chrome.extension.getURL('favicon.png'));
+ checkTarget(targets,
+ chrome.extension.getURL('_generated_background_page.html'),
+ 'other');
+
+ chrome.test.succeed();
+ });
+ }
+ chrome.tabs.onUpdated.addListener(onUpdated);
+ chrome.tabs.create({url: testPageUrl});
+ }
+]);
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/test/data/devtools/target_list/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698