2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / css-set-property-exception.html
blob39ae3e0c87094971d01b362baf399294426b0318
1 <html>
2 <head>
3 <script>
4 function log(message)
6 var item = document.createElement("li");
7 item.appendChild(document.createTextNode(message));
8 document.getElementById("console").appendChild(item);
10 function setInitialStyleForE()
12 var e = document.getElementById('e');
14 e.style.top = "0px";
15 e.style.bottom = "";
16 e.style.display = "none";
17 e.style.bottom = "1px";
19 function test()
21 if (window.layoutTestController)
22 layoutTestController.dumpAsText();
24 var e = document.getElementById('e');
26 setInitialStyleForE();
27 try {
28 e.style.display = "block";
29 log("Successfully set display to \"block\"; cssText is now: \"" + e.style.cssText + "\".");
30 } catch (exception) {
31 log("Got exception trying to set display to \"block\"; cssText is now: \"" + e.style.cssText + "\".");
34 setInitialStyleForE();
35 try {
36 e.style.display = "foobar";
37 log("Successfully set display to \"foobar\"; cssText is now: \"" + e.style.cssText + "\".");
38 } catch (exception) {
39 log("Got exception trying to set display to \"foobar\"; cssText is now: \"" + e.style.cssText + "\".");
42 setInitialStyleForE();
43 try {
44 e.style.display = "";
45 log("Successfully set display to \"\"; cssText is now: \"" + e.style.cssText + "\".");
46 } catch (exception) {
47 log("Got exception trying to set display to \"\"; cssText is now: \"" + e.style.cssText + "\".");
50 setInitialStyleForE();
51 try {
52 e.style.display = null;
53 log("Successfully set display to null; cssText is now: \"" + e.style.cssText + "\".");
54 } catch (exception) {
55 log("Got exception trying to set display to null; cssText is now: \"" + e.style.cssText + "\".");
58 setInitialStyleForE();
59 try {
60 e.style.setProperty("display", "block", "");
61 log("Successfully set display to \"block\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
62 } catch (exception) {
63 log("Got exception trying to set display to \"block\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
66 setInitialStyleForE();
67 try {
68 e.style.setProperty("display", "foobar", "");
69 log("Successfully set display to \"foobar\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
70 } catch (exception) {
71 log("Got exception trying to set display to \"foobar\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
74 setInitialStyleForE();
75 try {
76 e.style.setProperty("display", "", "");
77 log("Successfully set display to \"\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
78 } catch (exception) {
79 log("Got exception trying to set display to \"\" with setProperty; cssText is now: \"" + e.style.cssText + "\".");
82 setInitialStyleForE();
83 try {
84 e.style.setProperty("display", null, "");
85 log("Successfully set display to null with setProperty; cssText is now: \"" + e.style.cssText + "\".");
86 } catch (exception) {
87 log("Got exception trying to set display to null with setProperty; cssText is now: \"" + e.style.cssText + "\".");
90 </script>
91 </head>
92 <body onload="test();">
93 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=7296">bug 7296</a>.</p>
94 <p>This test checks to see whether you get exceptions when setting a property with a "bad value".
95 Setting using JavaScript property syntax and with setProperty() should behave the same.</p>
96 <P>It is OK if the order of properties changes from the expected results - IE 6 and Firefox 2 don't agree on it anyway.</p>
97 <hr>
98 <p id="e">This is the test element.</p>
99 <hr>
100 <ol id="console"></ol>
101 </body>
102 </html>