1 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 window
.enablePixelTesting
= true;
5 window
.jsTestIsAsync
= true;
7 <script src=
"../../resources/js-test.js"></script>
8 <script src=
"../../resources/run-after-layout-and-paint.js"></script>
9 <script type=
"text/javascript">
10 function repaintTest() {
11 // Test initial reported offsetWidth is 0, as we're not in the tree yet.
12 newObject
= document
.createElement("object");
13 newObject
.setAttribute("style", "border: 1px black solid; background: red");
14 shouldBe("newObject.offsetWidth", "0");
15 shouldBe("newObject.offsetWidth", "0");
17 // Test that the initial width is 300px + 1px border on each side.
18 document
.body
.insertBefore(newObject
, document
.getElementById("description"));
19 shouldBe("newObject.offsetWidth", "302");
20 shouldBe("newObject.offsetWidth", "302");
22 // Switch to document: "<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200"><rect width="400" height="200" fill="green"/><script><![CDATA[window.parent.postMessage('running', '*');]]></script></svg>".
24 // The replacement won't synchronous; wait on its completion.
25 window
.onmessage = function () {
26 shouldBe("newObject.offsetWidth", "402");
27 shouldBe("newObject.offsetWidth", "402");
30 newObject
.setAttribute("data", "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MDAiIGhlaWdodD0iMjAwIj48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iZ3JlZW4iLz48c2NyaXB0PjwhW0NEQVRBW3dpbmRvdy5wYXJlbnQucG9zdE1lc3NhZ2UoJ3J1bm5pbmcnLCAnKicpO11dPjwvc2NyaXB0Pjwvc3ZnPg==");
34 <body style=
"margin: 0px" onload=
"runAfterLayoutAndPaint(repaintTest);">
36 <p id=
"description"></p>
37 <div id=
"console"></div>
40 description("Tests that querying offsetWidth twice leads to the same result - no red background should be visible.");