WebCore:
[WebKit-https.git] / LayoutTests / fast / css / resources / CSSPrimitiveValue-exceptions.js
1 description("This tests that the methods on CSSPrimitiveValue throw exceptions ");
2
3 div = document.createElement('div');
4 div.style.width = "10px";
5 div.style.content = "counter(dummy, square)";
6 div.style.clip = "rect(0, 0, 1, 1)";
7 div.style.color = "rgb(0, 0, 0)";
8
9 var invalidAccessError = "Error: INVALID_ACCESS_ERR: DOM Exception 15";
10
11 // Test passing invalid unit to getFloatValue
12 shouldThrow("div.style.getPropertyCSSValue('width').getFloatValue(CSSPrimitiveValue.CSS_UNKNOWN)", "invalidAccessError");
13 shouldThrow("div.style.getPropertyCSSValue('width').getFloatValue(CSSPrimitiveValue.CSS_STRING)", "invalidAccessError");
14
15 // Test calling get*Value for CSSPrimitiveValue of the wrong type
16 shouldBe("div.style.getPropertyCSSValue('clip').primitiveType", "CSSPrimitiveValue.CSS_RECT");
17 shouldThrow("div.style.getPropertyCSSValue('clip').getFloatValue(CSSPrimitiveValue.CSS_PX)", "invalidAccessError");
18 shouldThrow("div.style.getPropertyCSSValue('clip').getStringValue()", "invalidAccessError");
19 shouldThrow("div.style.getPropertyCSSValue('clip').getCounterValue()", "invalidAccessError");
20 shouldThrow("div.style.getPropertyCSSValue('clip').getRGBColorValue()", "invalidAccessError");
21
22 shouldBe("div.style.getPropertyCSSValue('color').primitiveType", "CSSPrimitiveValue.CSS_RGBCOLOR");
23 shouldThrow("div.style.getPropertyCSSValue('color').getFloatValue(CSSPrimitiveValue.CSS_PX)", "invalidAccessError");
24 shouldThrow("div.style.getPropertyCSSValue('color').getStringValue()", "invalidAccessError");
25 shouldThrow("div.style.getPropertyCSSValue('color').getCounterValue()", "invalidAccessError");
26 shouldThrow("div.style.getPropertyCSSValue('color').getRectValue()", "invalidAccessError");
27
28 var successfullyParsed = true;