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

Unified Diff: LayoutTests/fast/css3-text/font-stretch.html

Issue 199423003: Add plumbing for font-stretch (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
Index: LayoutTests/fast/css3-text/font-stretch.html
diff --git a/LayoutTests/fast/css3-text/font-stretch.html b/LayoutTests/fast/css3-text/font-stretch.html
new file mode 100644
index 0000000000000000000000000000000000000000..905461ec0da074fbfa68767c399e8417d4aa6599
--- /dev/null
+++ b/LayoutTests/fast/css3-text/font-stretch.html
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ #test {
+ font-family: arial;
+ }
+ #test > div > span, #test > header > span {
+ display: inline-block;
+ width: 20ex;
+ }
+ #test > header {
+ font-weight: bold;
+ border-bottom: 1px solid black;
+ }
+ </style>
+ </head>
+ <body>
+ <section id="test">
+ <header><span>Assigned</span><span>Computed</span><span>Result</span></header>
+ </section>
+ <section>
+ <p>
+ Tests that all supported <code>font-stretch</code> values
+ are correctly parsed, recognized and returned from
+ <code>getComputedStyle</code>.
+ </p>
+ <p>
+ Also tests that a few invalid <code>font-stretch</code>
+ values are ignored as expected.
+ </p>
+ </section>
+ <script>
+ if (self.testRunner)
+ testRunner.dumpAsText();
+
+ function createElement(tagName, opt_style, opt_textContent)
+ {
+ var element = document.createElement(tagName);
+ element.style.cssText = opt_style || '';
+ if (opt_textContent)
+ element.appendChild(document.createTextNode(opt_textContent));
+ return element;
+ }
+ function testValues(containerElement, values, isValid)
+ {
+
+ for (var value, i = 0; value = values[i]; i++) {
+ var testElement = createElement('div');
+ var style = 'font-stretch: ' + value + '; font-weight: bold;';
+ testElement.appendChild(createElement('span', style, value));
+ containerElement.appendChild(testElement);
+ var style = window.getComputedStyle(testElement.firstChild);
+ testElement.appendChild(createElement('span', undefined, style.fontStretch));
+ var result;
+ if (style.fontStretch == value && isValid)
+ result = 'PASS';
+ else if (style.fontStretch == 'normal' && !isValid)
+ result = 'PASS';
+ else
+ result = 'FAIL';
+ testElement.appendChild(createElement('span', undefined, result));
+ }
+ }
+ var stretchValues = [
+ 'normal', 'ultra-condensed', 'extra-condensed',
+ 'condensed', 'semi-condensed', 'semi-expanded',
+ 'expanded', 'extra-expanded', 'ultra-expanded'
+ ];
+ var invalidValues = [
+ 'bold', 'semi-normal', 'very-condensed',
+ 'compact', 'foobar', '900'
+ ];
+ var containerElement = document.getElementById('test');
+ testValues(containerElement, stretchValues, true);
+ containerElement.appendChild(createElement('div', 'border-bottom: 1px solid black'));
+ testValues(containerElement, invalidValues, false);
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698