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

Unified Diff: LayoutTests/fast/dom/script-tests/setPrimitiveValue-exceptions.js

Issue 1549001: Merge 56663 - CSSPrimitiveValue::setFloatValue/setStringValue should throw an... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/WebKit/249/
Patch Set: Created 10 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
« no previous file with comments | « no previous file | LayoutTests/fast/dom/setPrimitiveValue-exceptions.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/script-tests/setPrimitiveValue-exceptions.js
===================================================================
--- LayoutTests/fast/dom/script-tests/setPrimitiveValue-exceptions.js (revision 0)
+++ LayoutTests/fast/dom/script-tests/setPrimitiveValue-exceptions.js (revision 42928)
@@ -0,0 +1,49 @@
+description("This test ensures that setting primitive values to an inappropriate unit type will throw an exception.");
+
+var element = document.createElement('div');
+element.id = "test-element"
+document.documentElement.appendChild(element);
+
+var styleElement = document.createElement('style');
+styleElement.innerText = "#test-element { left: 10px; font-family: Times; }";
+document.documentElement.appendChild(styleElement);
+
+var style = styleElement.sheet.cssRules[0].style;
+
+var left = style.getPropertyCSSValue("left");
+
+left.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, 25);
+shouldBe("left.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "25");
+
+left.setFloatValue(CSSPrimitiveValue.CSS_DIMENSION, 25);
+shouldBe("left.getFloatValue(CSSPrimitiveValue.CSS_DIMENSION)", "25");
+
+shouldThrow("left.setFloatValue(CSSPrimitiveValue.CSS_UNKNOWN, 25)");
+shouldThrow("left.setFloatValue(CSSPrimitiveValue.CSS_STRING, 25)");
+shouldThrow("left.getFloatValue(CSSPrimitiveValue.CSS_UNKNOWN)");
+shouldThrow("left.getFloatValue(CSSPrimitiveValue.CSS_STRING)");
+
+shouldThrow("left.getStringValue()");
+shouldThrow("left.getCounterValue()");
+shouldThrow("left.getRectValue()");
+shouldThrow("left.getRGBColorValue()");
+
+
+var fontFamily = style.getPropertyCSSValue("font-family")[0];
+
+fontFamily.setStringValue(CSSPrimitiveValue.CSS_STRING, "Hi there!");
+shouldBe("fontFamily.getStringValue()", '"Hi there!"');
+
+fontFamily.setStringValue(CSSPrimitiveValue.CSS_ATTR, "G'day!");
+shouldBe("fontFamily.getStringValue()", '"G\'day!"');
+
+shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_UNKNOWN, 'Hi there!')");
+shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_DIMENSION, \"G'day!\")");
+shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_COUNTER, 'Hello, world!')");
+
+shouldThrow("fontFamily.getFloatValue()");
+shouldThrow("fontFamily.getCounterValue()");
+shouldThrow("fontFamily.getRectValue()");
+shouldThrow("fontFamily.getRGBColorValue()");
+
+successfullyParsed = true;
« no previous file with comments | « no previous file | LayoutTests/fast/dom/setPrimitiveValue-exceptions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698