OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GEN('#include "chrome/test/data/webui/history_ui_browsertest.h"'); | 5 GEN('#include "chrome/test/data/webui/history_ui_browsertest.h"'); |
6 | 6 |
7 /** @const */ var TOTAL_RESULT_COUNT = 160; | 7 /** @const */ var TOTAL_RESULT_COUNT = 160; |
8 /** @const */ var WAIT_TIMEOUT = 200; | 8 /** @const */ var WAIT_TIMEOUT = 200; |
9 | 9 |
10 /** | 10 /** |
11 * Test fixture for history WebUI testing. | 11 * Test fixture for history WebUI testing. |
12 * @constructor | 12 * @constructor |
13 * @extends {testing.Test} | 13 * @extends {testing.Test} |
14 */ | 14 */ |
15 function HistoryUIBrowserTest() {} | 15 function HistoryUIBrowserTest() {} |
16 | 16 |
17 /** | 17 /** |
18 * Create a fake history result with the given timestamp. | 18 * Create a fake history result with the given timestamp. |
19 * @param {Number} timestamp Timestamp of the entry, in ms since the epoch. | 19 * @param {Number} timestamp Timestamp of the entry, in ms since the epoch. |
20 * @param {String} url The URL to set on this entry. | 20 * @param {String} url The URL to set on this entry. |
21 * @return {Object} An object representing a history entry. | 21 * @return {Object} An object representing a history entry. |
22 */ | 22 */ |
23 function createHistoryEntry(timestamp, url) { | 23 function createHistoryEntry(timestamp, url) { |
24 var d = new Date(timestamp); | 24 var d = new Date(timestamp); |
| 25 // Extract domain from url. |
| 26 var domainMatch = url.replace(/^.+?:\/\//, '').match(/[^/]+/); |
| 27 var domain = domainMatch ? domainMatch[0] : ''; |
25 return { | 28 return { |
26 dateTimeOfDay: d.getHours() + ':' + d.getMinutes(), | 29 dateTimeOfDay: d.getHours() + ':' + d.getMinutes(), |
27 dateRelativeDay: d.toDateString(), | 30 dateRelativeDay: d.toDateString(), |
28 allTimestamps: [timestamp], | 31 allTimestamps: [timestamp], |
29 starred: false, | 32 starred: false, |
30 time: timestamp, | 33 time: timestamp, |
31 title: d.toString(), // Use the stringified date as the title. | 34 title: d.toString(), // Use the stringified date as the title. |
32 url: url | 35 url: url, |
| 36 domain: domain |
33 }; | 37 }; |
34 } | 38 } |
35 | 39 |
36 /** | 40 /** |
37 * Wait for the history backend to call the global function named | 41 * Wait for the history backend to call the global function named |
38 * |callbackName|, and then execute |afterFunction|. This allows tests to | 42 * |callbackName|, and then execute |afterFunction|. This allows tests to |
39 * wait on asynchronous backend operations before proceeding. | 43 * wait on asynchronous backend operations before proceeding. |
40 */ | 44 */ |
41 function waitForCallback(callbackName, afterFunction) { | 45 function waitForCallback(callbackName, afterFunction) { |
42 var originalCallback = window[callbackName]; | 46 var originalCallback = window[callbackName]; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 var removeVisit = $('remove-visit'); | 825 var removeVisit = $('remove-visit'); |
822 expectTrue(removeVisit.disabled); | 826 expectTrue(removeVisit.disabled); |
823 | 827 |
824 // Attempting to remove items anyway should fail. | 828 // Attempting to remove items anyway should fail. |
825 historyModel.removeVisitsFromHistory(historyModel.visits_, function () { | 829 historyModel.removeVisitsFromHistory(historyModel.visits_, function () { |
826 // The callback is only called on success. | 830 // The callback is only called on success. |
827 testDone([false, 'Delete succeeded even though it was prohibited.']); | 831 testDone([false, 'Delete succeeded even though it was prohibited.']); |
828 }); | 832 }); |
829 waitForCallback('deleteFailed', testDone); | 833 waitForCallback('deleteFailed', testDone); |
830 }); | 834 }); |
| 835 |
| 836 /** |
| 837 * Fixture for History WebUI testing IDN. |
| 838 * @extends {BaseHistoryWebUITest} |
| 839 * @constructor |
| 840 */ |
| 841 function HistoryWebUIIDNTest() {} |
| 842 |
| 843 HistoryWebUIIDNTest.prototype = { |
| 844 __proto__: BaseHistoryWebUITest.prototype, |
| 845 |
| 846 /** @override */ |
| 847 testGenPreamble: function() { |
| 848 // Add some visits to the history database. |
| 849 GEN(' AddPageToHistory(0, "http://xn--d1abbgf6aiiy.xn--p1ai/",' + |
| 850 ' "Some");'); |
| 851 |
| 852 // Clear AcceptLanguages to get domain in unicode. |
| 853 GEN(' ClearAcceptLanguages();'); |
| 854 }, |
| 855 }; |
| 856 |
| 857 /** |
| 858 * Simple test that verifies that the correct entries are retrieved from the |
| 859 * history database and displayed in the UI. |
| 860 */ |
| 861 TEST_F('HistoryWebUIIDNTest', 'basic', function() { |
| 862 // Check that there is only one entry and domain is in unicode. |
| 863 assertEquals(1, document.querySelectorAll('.domain').length); |
| 864 assertEquals("\u043f\u0440\u0435\u0437\u0438\u0434\u0435\u043d\u0442." + |
| 865 "\u0440\u0444", document.querySelector('.domain').textContent); |
| 866 |
| 867 testDone(); |
| 868 }); |
OLD | NEW |