3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
4 <script type=
"text/javascript">
7 function createFakeTab(title
, width
)
13 return { width: function() { return width
; }, title
: title
, toString
: toString
};
16 var tabbedPane
= new WebInspector
.TabbedPane();
17 tabbedPane
.setAllowTabReorder(true, true);
19 var dropDownButtonMeasuredWidth
= 10;
20 function getTabsToShowAndDumpResults(tabsOrdered
, tabsHistory
, totalWidth
)
22 var tabsToShowIndexes
= WebInspector
.TabbedPane
.prototype._tabsToShowIndexes
.call(tabbedPane
, tabsOrdered
, tabsHistory
, totalWidth
, dropDownButtonMeasuredWidth
);
23 InspectorTest
.addResult(" tabsToShowIndexes = [" + String(tabsToShowIndexes
) + "]");
26 function testWidthsAndHistory(widths
, history
, totalWidth
)
30 for (var i
= 0; i
< widths
.length
; i
++)
31 tabsOrdered
.push(createFakeTab("tab " + i
, widths
[i
]));
32 for (var i
= 0; i
< history
.length
; i
++)
33 tabsHistory
.push(tabsOrdered
[history
[i
]]);
34 InspectorTest
.addResult("Running tabs to show test:");
35 InspectorTest
.addResult(" widths = [" + String(widths
) + "]");
36 InspectorTest
.addResult(" tabsHistory = [" + String(tabsHistory
) + "]");
37 InspectorTest
.addResult(" totalWidth = " + totalWidth
+ ", dropDownButtonMeasuredWidth = " + dropDownButtonMeasuredWidth
);
38 getTabsToShowAndDumpResults(tabsOrdered
, tabsHistory
, totalWidth
);
41 function testWithDifferentTotalWidths(widths
, history
)
43 testWidthsAndHistory(widths
, history
, 370);
44 testWidthsAndHistory(widths
, history
, 360);
45 testWidthsAndHistory(widths
, history
, 350);
46 testWidthsAndHistory(widths
, history
, 300);
47 testWidthsAndHistory(widths
, history
, 250);
48 testWidthsAndHistory(widths
, history
, 200);
49 testWidthsAndHistory(widths
, history
, 150);
50 testWidthsAndHistory(widths
, history
, 100);
51 testWidthsAndHistory(widths
, history
, 60);
52 testWidthsAndHistory(widths
, history
, 50);
53 InspectorTest
.addResult("");
56 var widths
= [50, 50, 60, 60, 70, 70];
57 testWithDifferentTotalWidths(widths
, [0, 1, 2, 3, 4, 5]);
58 testWithDifferentTotalWidths(widths
, [5, 4, 3, 2, 1, 0]);
59 testWithDifferentTotalWidths(widths
, [0, 2, 4, 1, 3, 5]);
60 testWithDifferentTotalWidths(widths
, [5, 3, 1, 4, 2, 0]);
62 tabbedPane
.setAllowTabReorder(false);
64 testWithDifferentTotalWidths(widths
, [0, 1, 2, 3, 4, 5]);
65 testWithDifferentTotalWidths(widths
, [5, 4, 3, 2, 1, 0]);
66 testWithDifferentTotalWidths(widths
, [0, 2, 4, 1, 3, 5]);
67 testWithDifferentTotalWidths(widths
, [5, 3, 1, 4, 2, 0]);
69 InspectorTest
.completeTest();
73 <body onload=
"runTest()">
74 <p>Tests tabbed pane tabs to show calculation.
</p>
75 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=75085">Bug
75085</a>