Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Test fixture for testing async methods of cr.js. | |
| 7 * @constructor | |
| 8 * @extends testing.Test | |
| 9 */ | |
| 10 function TextDefaultsTest() {} | |
| 11 | |
| 12 TextDefaultsTest.prototype = { | |
| 13 __proto__: testing.Test.prototype, | |
| 14 | |
| 15 /** | |
| 16 * Must be on same domain as text_defaults.css (chrome://resources). | |
| 17 * @override | |
| 18 */ | |
| 19 browsePreload: 'chrome://resources/html/assert.html', | |
| 20 | |
| 21 /** @override */ | |
| 22 isAsync: true, | |
| 23 }; | |
| 24 | |
| 25 /** | |
| 26 * @param {string} html Text, possibly with HTML &entities; in it. | |
| 27 * @return {string} The HTML decoded text of |maybeHtml|. | |
|
dschuyler
2016/04/07 20:54:31
nit: The param name is called html and maybeHtml i
Dan Beam
2016/04/07 21:03:46
Done.
| |
| 28 */ | |
| 29 function decodeHtmlEntities(html) { | |
| 30 var element = document.createElement('div'); | |
| 31 element.innerHTML = html; | |
| 32 return element.textContent; | |
| 33 } | |
| 34 | |
| 35 TEST_F('TextDefaultsTest', 'ScrapeStyles', function() { | |
| 36 var link = document.createElement('link'); | |
| 37 link.rel = 'stylesheet'; | |
| 38 link.href = 'chrome://resources/css/text_defaults.css'; | |
| 39 link.onload = function() { | |
| 40 var fontFamily = link.sheet.rules[1].style['font-family']; | |
| 41 assertNotEquals('', fontFamily); | |
| 42 assertEquals(decodeHtmlEntities(fontFamily), fontFamily); | |
| 43 testDone(); | |
| 44 }; | |
| 45 document.body.appendChild(link); | |
| 46 }); | |
| 47 | |
| 48 TEST_F('TextDefaultsTest', 'ScrapeMDStyles', function() { | |
| 49 var link = document.createElement('link'); | |
| 50 link.rel = 'stylesheet'; | |
| 51 link.href = 'chrome://resources/css/text_defaults_md.css'; | |
| 52 link.onload = function() { | |
| 53 var fontFamily = link.sheet.rules[2].style['font-family']; | |
| 54 assertNotEquals('', fontFamily); | |
| 55 assertEquals(decodeHtmlEntities(fontFamily), fontFamily); | |
| 56 testDone(); | |
| 57 }; | |
| 58 document.body.appendChild(link); | |
| 59 }); | |
| OLD | NEW |