<html>
<head>
+<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#dom-document-dir"/>
<script>
var headReadDocumentDir = document.dir;
document.dir = "rtl";
</script>
</head>
<body>
-<div id="description"></div>
-<div id="console"></div>
<script src="../../resources/js-test.js"></script>
<script>
-description("This tests:<br>"
- + "Bug 9954 REGRESSION: document.dir should return empty string in <head><br>"
- + "<a href=\"https://bugs.webkit.org/show_bug.cgi?id=9954\">https://bugs.webkit.org/show_bug.cgi?id=9954</a><br>");
+description("document.dir should reflect the 'dir' content attribute of the <html> element and should be settable in <head>.");
debug("Read document.dir in head");
-shouldBe("headReadDocumentDir", "''");
+shouldBeEqualToString("headReadDocumentDir", "");
debug("");
debug("Write document.dir in head");
-shouldBe("headWriteDocumentDir", "''");
+shouldBeEqualToString("headWriteDocumentDir", "rtl");
debug("");
debug("Read document.dir in body");
-shouldBe("document.dir", "''");
+shouldBeEqualToString("document.dir", "rtl");
+debug("");
+
+debug("Read document.documentElement.dir in body");
+shouldBeEqualToString("document.documentElement.dir", "rtl");
debug("");
debug("Read document.body.dir in body");
-shouldBe("document.body.dir", "''");
+shouldBeEqualToString("document.body.dir", "");
debug("");
debug("Write document.dir in body");
document.dir = "ltr";
-shouldBe("document.dir", "'ltr'");
+shouldBeEqualToString("document.dir", "ltr");
+debug("");
+
+debug("Read document.documentElement.dir in body");
+shouldBeEqualToString("document.documentElement.dir", "ltr");
debug("");
debug("Read document.body.dir in body");
-shouldBe("document.body.dir", "'ltr'");
+shouldBeEqualToString("document.body.dir", "");
+debug("");
+
+debug("Write non-canonical case document.dir in body");
+shouldNotThrow("document.dir = 'RTL'");
+shouldBeEqualToString("document.dir", "rtl");
+debug("");
+
+debug("Write invalid document.dir in body");
+shouldNotThrow("document.dir = 'WRONG'");
+shouldBeEqualToString("document.dir", "");
+debug("");
+
+debug("Write non-canonical case document.body.dir in body");
+shouldNotThrow("document.body.dir = 'RTL'");
+shouldBeEqualToString("document.body.dir", "rtl");
+debug("");
+
+debug("Write invalid document.body.dir in body");
+shouldNotThrow("document.body.dir = 'WRONG'");
+shouldBeEqualToString("document.body.dir", "");
debug("");
</script>
</body>