Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | XUL Widget Test for tree using a custom nsITreeView |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Tree" onload="init()" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <script src="tree_shared.js"/> |
michael@0 | 13 | |
michael@0 | 14 | <script> |
michael@0 | 15 | <![CDATA[ |
michael@0 | 16 | |
michael@0 | 17 | // This is our custom view, based on the treeview interface |
michael@0 | 18 | var view = |
michael@0 | 19 | { |
michael@0 | 20 | treeData: [["Mary", "206 Garden Avenue"], |
michael@0 | 21 | ["Chris", "19 Marion Street"], |
michael@0 | 22 | ["Sarah", "702 Fern Avenue"], |
michael@0 | 23 | ["John", "99 Westminster Avenue"]], |
michael@0 | 24 | value: "", |
michael@0 | 25 | rowCount: 8, |
michael@0 | 26 | getCellText: function(row, column) { return this.treeData[row % 4][column.index]; }, |
michael@0 | 27 | getCellValue: function(row, column) { return this.value; }, |
michael@0 | 28 | setCellText: function(row, column, val) { this.treeData[row % 4][column.index] = val; }, |
michael@0 | 29 | setCellValue: function(row, column, val) { this.value = val; }, |
michael@0 | 30 | setTree: function(tree) { this.tree = tree; }, |
michael@0 | 31 | isContainer: function(row) { return false; }, |
michael@0 | 32 | isContainerOpen: function(row) { return false; }, |
michael@0 | 33 | isContainerEmpty: function(row) { return false; }, |
michael@0 | 34 | isSeparator: function(row) { return false; }, |
michael@0 | 35 | isSorted: function(row) { return false; }, |
michael@0 | 36 | isSelectable: function(row, column) { return true; }, |
michael@0 | 37 | isEditable: function(row, column) { return row != 2 || column.index != 1; }, |
michael@0 | 38 | getProgressMode: function(row, column) { return Components.interfaces.nsITreeView.PROGRESS_NORMAL; }, |
michael@0 | 39 | getParentIndex: function(row, column) { return -1; }, |
michael@0 | 40 | getLevel: function(row) { return 0; }, |
michael@0 | 41 | hasNextSibling: function(row, column) { return row != this.rowCount - 1; }, |
michael@0 | 42 | getImageSrc: function(row, column) { return ""; }, |
michael@0 | 43 | cycleHeader: function(column) { }, |
michael@0 | 44 | getRowProperties: function(row) { return ""; }, |
michael@0 | 45 | getCellProperties: function(row, column) { return ""; }, |
michael@0 | 46 | getColumnProperties: function(column) |
michael@0 | 47 | { |
michael@0 | 48 | if (!column.index) { |
michael@0 | 49 | return "one two"; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | return ""; |
michael@0 | 53 | } |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function getCustomTreeViewCellInfo() |
michael@0 | 57 | { |
michael@0 | 58 | var obj = { rows: [] }; |
michael@0 | 59 | |
michael@0 | 60 | for (var row = 0; row < view.rowCount; row++) { |
michael@0 | 61 | var cellInfo = [ ]; |
michael@0 | 62 | for (var column = 0; column < 1; column++) { |
michael@0 | 63 | cellInfo.push({ label: "" + view.treeData[row % 4][column], |
michael@0 | 64 | value: "", |
michael@0 | 65 | properties: "", |
michael@0 | 66 | editable: row != 2 || column.index != 1, |
michael@0 | 67 | selectable: true, |
michael@0 | 68 | image: "", |
michael@0 | 69 | mode: Components.interfaces.nsITreeView.PROGRESS_NORMAL }); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | obj.rows.push({ cells: cellInfo, |
michael@0 | 73 | properties: "", |
michael@0 | 74 | container: false, |
michael@0 | 75 | separator: false, |
michael@0 | 76 | children: null, |
michael@0 | 77 | level: 0, |
michael@0 | 78 | parent: -1 }); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | return obj; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function init() |
michael@0 | 85 | { |
michael@0 | 86 | var tree = document.getElementById("tree-view"); |
michael@0 | 87 | tree.view = view; |
michael@0 | 88 | tree.treeBoxObject.ensureRowIsVisible(0); |
michael@0 | 89 | is(tree.treeBoxObject.getFirstVisibleRow(), 0, "first visible after ensureRowIsVisible on load"); |
michael@0 | 90 | tree.setAttribute("rows", "4"); |
michael@0 | 91 | |
michael@0 | 92 | setTimeout(testtag_tree, 0, "tree-view", "treechildren-view", "multiple", "simple", "tree view"); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | ]]> |
michael@0 | 96 | </script> |
michael@0 | 97 | |
michael@0 | 98 | <tree id="tree-view"> |
michael@0 | 99 | <treecols> |
michael@0 | 100 | <treecol id="name" label="Name" sort="label" flex="1"/> |
michael@0 | 101 | <treecol id="address" label="Address" flex="1"/> |
michael@0 | 102 | </treecols> |
michael@0 | 103 | <treechildren id="treechildren-view"/> |
michael@0 | 104 | </tree> |
michael@0 | 105 | |
michael@0 | 106 | <!-- test results are displayed in the html:body --> |
michael@0 | 107 | <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
michael@0 | 108 | |
michael@0 | 109 | <!-- test code goes here --> |
michael@0 | 110 | <script type="application/javascript"><![CDATA[ |
michael@0 | 111 | |
michael@0 | 112 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 113 | |
michael@0 | 114 | ]]> |
michael@0 | 115 | </script> |
michael@0 | 116 | |
michael@0 | 117 | </window> |
michael@0 | 118 |