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

Unified Diff: chrome/test/data/webui/text_defaults_browsertest.js

Issue 1863963004: WebUI: add functional test for text_defaults.css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment change Created 4 years, 8 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/test/base/web_ui_browser_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/text_defaults_browsertest.js
diff --git a/chrome/test/data/webui/text_defaults_browsertest.js b/chrome/test/data/webui/text_defaults_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..47491bb01fb7e83c1e735ef2d9322399dd32bbc7
--- /dev/null
+++ b/chrome/test/data/webui/text_defaults_browsertest.js
@@ -0,0 +1,59 @@
+// Copyright 2016 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.
+
+/**
+ * Test fixture for testing async methods of cr.js.
+ * @constructor
+ * @extends testing.Test
+ */
+function TextDefaultsTest() {}
+
+TextDefaultsTest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ /**
+ * Must be on same domain as text_defaults.css (chrome://resources).
+ * @override
+ */
+ browsePreload: 'chrome://resources/html/assert.html',
+
+ /** @override */
+ isAsync: true,
+};
+
+/**
+ * @param {string} html Text, possibly with HTML &entities; in it.
+ * @return {string} The HTML decoded text.
+ */
+function decodeHtmlEntities(html) {
+ var element = document.createElement('div');
+ element.innerHTML = html;
+ return element.textContent;
+}
+
+TEST_F('TextDefaultsTest', 'ScrapeStyles', function() {
+ var link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = 'chrome://resources/css/text_defaults.css';
+ link.onload = function() {
+ var fontFamily = link.sheet.rules[1].style['font-family'];
+ assertNotEquals('', fontFamily);
+ assertEquals(decodeHtmlEntities(fontFamily), fontFamily);
+ testDone();
+ };
+ document.body.appendChild(link);
+});
+
+TEST_F('TextDefaultsTest', 'ScrapeMDStyles', function() {
+ var link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = 'chrome://resources/css/text_defaults_md.css';
+ link.onload = function() {
+ var fontFamily = link.sheet.rules[2].style['font-family'];
+ assertNotEquals('', fontFamily);
+ assertEquals(decodeHtmlEntities(fontFamily), fontFamily);
+ testDone();
+ };
+ document.body.appendChild(link);
+});
« no previous file with comments | « chrome/test/base/web_ui_browser_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698