| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 var expectedEventData; | 5 var expectedEventData; |
| 6 var capturedEventData; | 6 var capturedEventData; |
| 7 var shouldIgnore; | 7 var shouldIgnore; |
| 8 | 8 |
| 9 function expect(data, ignoreFunc) { | 9 function expect(data, ignoreFunc) { |
| 10 expectedEventData = data; | 10 expectedEventData = data; |
| 11 capturedEventData = []; | 11 capturedEventData = []; |
| 12 shouldIgnore = ignoreFunc; | 12 shouldIgnore = ignoreFunc; |
| 13 } | 13 } |
| 14 | 14 |
| 15 function checkExpectations() { | 15 function checkExpectations() { |
| 16 if (capturedEventData.length < expectedEventData.length) { | 16 if (capturedEventData.length < expectedEventData.length) { |
| 17 return; | 17 return; |
| 18 } | 18 } |
| 19 chrome.test.assertEq(JSON.stringify(expectedEventData), | 19 chrome.test.assertEq(JSON.stringify(expectedEventData), |
| 20 JSON.stringify(capturedEventData)); | 20 JSON.stringify(capturedEventData)); |
| 21 chrome.test.succeed(); | 21 chrome.test.succeed(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 var getURL = chrome.extension.getURL; | 24 var getURL = chrome.extension.getURL; |
| 25 | 25 |
| 26 chrome.tabs.onUpdated.addListener(function(tabId, info, tab) { | 26 chrome.tabs.onUpdated.addListener(function(tabId, info, tab) { |
| 27 console.log('---onUpdated: ' + info.status + ', ' + info.url); | 27 console.log('---onUpdated: ' + info.status + ', ' + info.url + '. ' + |
| 28 info.favIconUrl); |
| 28 if (shouldIgnore && shouldIgnore(info)) { | 29 if (shouldIgnore && shouldIgnore(info)) { |
| 29 return; | 30 return; |
| 30 } | 31 } |
| 31 capturedEventData.push(info); | 32 capturedEventData.push(info); |
| 32 checkExpectations(); | 33 checkExpectations(); |
| 33 }); | 34 }); |
| 34 | 35 |
| 35 chrome.test.runTests([ | 36 chrome.test.runTests([ |
| 36 function browserThenRendererInitiated() { | 37 function browserThenRendererInitiated() { |
| 37 // Note that a.html will set it's location.href to b.html, creating a | 38 // Note that a.html will set it's location.href to b.html, creating a |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 function internalAnchorNavigated() { | 103 function internalAnchorNavigated() { |
| 103 expect([ | 104 expect([ |
| 104 { status: 'loading', url: getURL('internalAnchorNavigated/a.html') }, | 105 { status: 'loading', url: getURL('internalAnchorNavigated/a.html') }, |
| 105 { status: 'complete' }, | 106 { status: 'complete' }, |
| 106 { status: 'loading', url: getURL('internalAnchorNavigated/a.html#b') }, | 107 { status: 'loading', url: getURL('internalAnchorNavigated/a.html#b') }, |
| 107 { status: 'complete' }, | 108 { status: 'complete' }, |
| 108 ]); | 109 ]); |
| 109 | 110 |
| 110 chrome.tabs.create({ url: getURL('internalAnchorNavigated/a.html') }); | 111 chrome.tabs.create({ url: getURL('internalAnchorNavigated/a.html') }); |
| 112 }, |
| 113 |
| 114 function faviconLoaded() { |
| 115 expect([ |
| 116 { status: 'loading', url: getURL('favicon/a.html') }, |
| 117 { status: 'complete' }, |
| 118 { favIconUrl: getURL('favicon/favicon.png') }, |
| 119 ]); |
| 120 |
| 121 chrome.tabs.create({ url: getURL('favicon/a.html') }); |
| 111 } | 122 } |
| 112 ]); | 123 ]); |
| OLD | NEW |