| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 function requestUrl(url, callback) { | 5 function requestUrl(url, callback) { |
| 6 var req = new XMLHttpRequest(); | 6 var req = new XMLHttpRequest(); |
| 7 req.open('GET', url, true); | 7 req.open('GET', url, true); |
| 8 req.onload = function() { | 8 req.onload = function() { |
| 9 if (req.status == 200) | 9 if (req.status == 200) |
| 10 callback(req.responseText); | 10 callback(req.responseText); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 if (!target) | 25 if (!target) |
| 26 chrome.test.fail('Cannot find a target with url ' + url); | 26 chrome.test.fail('Cannot find a target with url ' + url); |
| 27 | 27 |
| 28 var wsAddress = REMOTE_DEBUGGER_HOST + '/devtools/page/' + target.id; | 28 var wsAddress = REMOTE_DEBUGGER_HOST + '/devtools/page/' + target.id; |
| 29 | 29 |
| 30 chrome.test.assertEq( | 30 chrome.test.assertEq( |
| 31 '/devtools/devtools.html?ws=' + wsAddress, | 31 '/devtools/devtools.html?ws=' + wsAddress, |
| 32 target.devtoolsFrontendUrl); | 32 target.devtoolsFrontendUrl); |
| 33 // On some platforms (e.g. Chrome OS) target.faviconUrl might be empty for | 33 // On some platforms (e.g. Chrome OS) target.faviconUrl might be empty for |
| 34 // a freshly created tab. Ignore the check then. | 34 // a freshly created tab. Ignore the check then. |
| 35 if (target.faviconUrl && opt_faviconUrl) | 35 if (target.faviconUrl) |
| 36 chrome.test.assertEq(opt_faviconUrl, target.faviconUrl); | 36 chrome.test.assertEq(opt_faviconUrl, target.faviconUrl); |
| 37 // Sometimes thumbnailUrl is not available for a freshly loaded tab. | 37 // Sometimes thumbnailUrl is not available for a freshly loaded tab. |
| 38 if (target.thumbnailUrl) | 38 if (target.thumbnailUrl) |
| 39 chrome.test.assertEq('/thumb/' + target.id, target.thumbnailUrl); | 39 chrome.test.assertEq('/thumb/' + target.id, target.thumbnailUrl); |
| 40 chrome.test.assertEq(opt_title || target.url, target.title); | 40 chrome.test.assertEq(opt_title || target.url, target.title); |
| 41 chrome.test.assertEq(type, target.type); | 41 chrome.test.assertEq(type, target.type); |
| 42 chrome.test.assertEq('ws://' + wsAddress, target.webSocketDebuggerUrl); | 42 chrome.test.assertEq('ws://' + wsAddress, target.webSocketDebuggerUrl); |
| 43 } | 43 } |
| 44 | 44 |
| 45 chrome.test.runTests([ | 45 chrome.test.runTests([ |
| 46 function discoverTargets() { | 46 function discoverTargets() { |
| 47 var testPageUrl = chrome.extension.getURL('test_page.html'); | 47 var testPageUrl = chrome.extension.getURL('test_page.html'); |
| 48 | 48 |
| 49 function onUpdated() { | 49 function onUpdated() { |
| 50 chrome.tabs.onUpdated.removeListener(onUpdated); | 50 chrome.tabs.onUpdated.removeListener(onUpdated); |
| 51 requestUrl('http://' + REMOTE_DEBUGGER_HOST + '/json', function(text) { | 51 requestUrl('http://' + REMOTE_DEBUGGER_HOST + '/json', function(text) { |
| 52 var targets = JSON.parse(text); | 52 var targets = JSON.parse(text); |
| 53 | 53 |
| 54 checkTarget(targets, 'about:blank', 'page'); | 54 checkTarget(targets, 'about:blank', 'page'); |
| 55 checkTarget(targets, testPageUrl, 'page', 'Test page', | 55 checkTarget(targets, testPageUrl, 'page', 'Test page', |
| 56 chrome.extension.getURL('favicon.png')); | 56 chrome.extension.getURL('favicon.png')); |
| 57 checkTarget(targets, | 57 checkTarget(targets, |
| 58 chrome.extension.getURL('_generated_background_page.html'), | 58 chrome.extension.getURL('_generated_background_page.html'), |
| 59 'background_page', | 59 'other'); |
| 60 'Remote Debugger Test'); | |
| 61 | 60 |
| 62 chrome.test.succeed(); | 61 chrome.test.succeed(); |
| 63 }); | 62 }); |
| 64 } | 63 } |
| 65 chrome.tabs.onUpdated.addListener(onUpdated); | 64 chrome.tabs.onUpdated.addListener(onUpdated); |
| 66 chrome.tabs.create({url: testPageUrl}); | 65 chrome.tabs.create({url: testPageUrl}); |
| 67 } | 66 } |
| 68 ]); | 67 ]); |
| OLD | NEW |