019da4b919d911b33439a8ca4c890cf67110a61e
[WebKit-https.git] / LayoutTests / fast / attachment / attachment-subtitle-resize.html
1 <!DOCTYPE html>
2 <html>
3 <script src="../../resources/js-test-pre.js"></script>
4 <script>
5     if (window.internals)
6         window.internals.settings.setAttachmentElementEnabled(true)
7 </script>
8 <body>
9 <attachment id="wideAttachment" subtitle="VERY LONG SUBTITLE THAT WILL MAKE THE ATTACHMENT VERY WIDE"></attachment>
10 <attachment id="skinnyAttachment" subtitle="skinny but wider than icon"></attachment>
11 <attachment id="resizedAttachment" subtitle="skinny but wider than icon"></attachment>
12 <script>
13 description("This tests that attachments which resize will only grow in width, never shrink.");
14
15 var wideAttachmentEl = document.getElementById("wideAttachment");
16 var skinnyAttachmentEl = document.getElementById("skinnyAttachment");
17 var resizedAttachmentEl = document.getElementById("resizedAttachment");
18
19 var wideAttachmentWidth = wideAttachmentEl.offsetWidth;
20 var skinnyAttachmentWidth = skinnyAttachmentEl.offsetWidth;
21
22 function assert(value, description)
23 {
24     if (value)
25         testPassed(description);
26     else
27         testFailed(description);
28 }
29
30 assert(wideAttachmentWidth > skinnyAttachmentWidth, "wideAttachmentWidth > skinnyAttachmentWidth");
31
32 assert(resizedAttachmentEl.offsetWidth == skinnyAttachmentWidth, "Attachment starts out skinny.");
33
34 resizedAttachmentEl.setAttribute("subtitle", "VERY LONG SUBTITLE THAT WILL MAKE THE ATTACHMENT VERY WIDE");
35 assert(resizedAttachmentEl.offsetWidth == wideAttachmentWidth, "Attachment resized from skinny to wide becomes wide.");
36
37 resizedAttachmentEl.setAttribute("subtitle", "skinny but wider than icon");
38 assert(resizedAttachmentEl.offsetWidth == wideAttachmentWidth, "Attachment resized from wide to skinny remains wide.");
39
40 </script>
41 <script src="../../resources/js-test-post.js"></script>
42 </body>
43 </html>