| OLD | NEW |
| (Empty) | |
| 1 description("This test ensures that setting primitive values to an inappropriate
unit type will throw an exception."); |
| 2 |
| 3 var element = document.createElement('div'); |
| 4 element.id = "test-element" |
| 5 document.documentElement.appendChild(element); |
| 6 |
| 7 var styleElement = document.createElement('style'); |
| 8 styleElement.innerText = "#test-element { left: 10px; font-family: Times; }"; |
| 9 document.documentElement.appendChild(styleElement); |
| 10 |
| 11 var style = styleElement.sheet.cssRules[0].style; |
| 12 |
| 13 var left = style.getPropertyCSSValue("left"); |
| 14 |
| 15 left.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, 25); |
| 16 shouldBe("left.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "25"); |
| 17 |
| 18 left.setFloatValue(CSSPrimitiveValue.CSS_DIMENSION, 25); |
| 19 shouldBe("left.getFloatValue(CSSPrimitiveValue.CSS_DIMENSION)", "25"); |
| 20 |
| 21 shouldThrow("left.setFloatValue(CSSPrimitiveValue.CSS_UNKNOWN, 25)"); |
| 22 shouldThrow("left.setFloatValue(CSSPrimitiveValue.CSS_STRING, 25)"); |
| 23 shouldThrow("left.getFloatValue(CSSPrimitiveValue.CSS_UNKNOWN)"); |
| 24 shouldThrow("left.getFloatValue(CSSPrimitiveValue.CSS_STRING)"); |
| 25 |
| 26 shouldThrow("left.getStringValue()"); |
| 27 shouldThrow("left.getCounterValue()"); |
| 28 shouldThrow("left.getRectValue()"); |
| 29 shouldThrow("left.getRGBColorValue()"); |
| 30 |
| 31 |
| 32 var fontFamily = style.getPropertyCSSValue("font-family")[0]; |
| 33 |
| 34 fontFamily.setStringValue(CSSPrimitiveValue.CSS_STRING, "Hi there!"); |
| 35 shouldBe("fontFamily.getStringValue()", '"Hi there!"'); |
| 36 |
| 37 fontFamily.setStringValue(CSSPrimitiveValue.CSS_ATTR, "G'day!"); |
| 38 shouldBe("fontFamily.getStringValue()", '"G\'day!"'); |
| 39 |
| 40 shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_UNKNOWN, 'Hi there!
')"); |
| 41 shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_DIMENSION, \"G'day!
\")"); |
| 42 shouldThrow("fontFamily.setStringValue(CSSPrimitiveValue.CSS_COUNTER, 'Hello, wo
rld!')"); |
| 43 |
| 44 shouldThrow("fontFamily.getFloatValue()"); |
| 45 shouldThrow("fontFamily.getCounterValue()"); |
| 46 shouldThrow("fontFamily.getRectValue()"); |
| 47 shouldThrow("fontFamily.getRGBColorValue()"); |
| 48 |
| 49 successfullyParsed = true; |
| OLD | NEW |