layout/reftests/table-dom/tableDom.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 var count = 1;
     7 function genName(prefix) {
     8   return "X" + count++ + "\n";
     9 }
    11 function appendCell(aRow, aRowSpan, aColSpan) {
    12   var cell = document.createElement("TD", null);
    13   cell.rowSpan = aRowSpan;
    14   cell.colSpan = aColSpan;
    15   var text = document.createTextNode(genName());
    16   cell.appendChild(text);
    17   aRow.appendChild(cell);
    18 }
    20 function appendCellAt(aRowIndex, aRowSpan, aColSpan) {
    21   var row = document.getElementsByTagName("TR")[aRowIndex];
    22   appendCell(row, aRowSpan, aColSpan);
    23 }
    25 function insertCell(aRow, aColIndex, aRowSpan, aColSpan) {
    26   var cells = aRow.cells;
    27   var refCell = cells.item(aColIndex);
    28   var newCell = document.createElement("TD", null);
    29   newCell.rowSpan = aRowSpan;
    30   newCell.colSpan = aColSpan;
    31   var text = document.createTextNode(genName());
    32   newCell.appendChild(text);
    33   aRow.insertBefore(newCell, refCell);
    34   //dump("SCRIPT: inserted  CELL as first cell in first row\n");
    35 }
    37 function insertCellAt(aRowIndex, aColIndex, aRowSpan, aColSpan) {
    38   var row = document.getElementsByTagName("TR")[aRowIndex];
    39   insertCell(row, aColIndex, aRowSpan, aColSpan);
    40 }
    42 function deleteCell(aRow, aColIndex) {
    43   aRow.deleteCell(aColIndex);
    44 }
    46 function deleteCellAt(aRowIndex, aColIndex) {
    47   var row = document.getElementsByTagName("TR")[aRowIndex];
    48   deleteCell(row, aColIndex);
    49 }
    51 //function appendRow(aRowGroup) {
    52 //  var row = document.createElement("TR", null);
    53 //  cell = document.createElement("TD", null);
    54 //  row.appendChild(cell);
    55 //  aRowGroup.appendChild(row);
    56 //}
    58 function appendRow(aRowGroup) {
    59   var row = document.createElement("TR", null);
    60   cell = document.createElement("TD", null);
    61   aRowGroup.appendChild(row);
    62   //row.appendChild(cell);
    63   //appendCell(row, 1, 1);
    64 }
    66 function appendRowAt(aRowGroupIndex) {
    67   var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
    68   appendRow(rowGroup);
    69 }
    71 function insertRow(aRowGroup, aRowIndex) {
    72   var rows = aRowGroup.rows;
    73   var refRow = rows.item(aRowIndex);
    74   var row = document.createElement("TR", null);
    75   aRowGroup.insertBefore(row, refRow);
    76   //appendCell(row, 1, 1);
    77 }
    79 function insertRowAt(aRowGroupIndex, aRowIndex) {
    80   var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
    81   insertRow(rowGroup, aRowIndex);
    82 }
    84 function deleteRow(aRowGroup, aRowIndex) {
    85   aRowGroup.deleteRow(aRowIndex);
    86 }
    88 function deleteRowAt(aRowGroupIndex, aRowIndex) {
    89   var row = document.getElementsByTagName("TBODY")[aRowGroupIndex];
    90   deleteRow(row, aRowIndex);
    91 }
    93 function insertTbody(aTable, aTbodyIndex) {
    94   var tbodies = aTable.tBodies;
    95   var refTbody = tbodies.item(aTbodyIndex);
    96   var tbody = document.createElement("TBODY", null);
    97   aTable.insertBefore(tbody, refTbody);
    98 }
   100 function insertTbodyAt(aTableIndex, aTbodyIndex) {
   101   var table = document.getElementsByTagName("TABLE")[aTableIndex];
   102   insertTbodyAt(table, aTbodyIndex);
   103 }
   105 function deleteTbody(aTable, aTbodyIndex) {
   106   var tbodies = aTable.tBodies;
   107   var tbody = tbodies.item(aTbodyIndex);
   108   aTable.removeChild(tbody);
   109 }
   111 function deleteTbodyAt(aTableIndex, aTbodyIndex) {
   112   var table = document.getElementsByTagName("TABLE")[aTableIndex];
   113   deleteTbody(table, aTbodyIndex);
   114 }
   116 function buildTable(aNumRows, aNumCols) {
   117   var table = document.getElementsByTagName("TABLE")[0];
   118   for (rowX = 0; rowX < aNumRows; rowX++) {
   119     var row = document.createElement("TR", null);
   120 	  for (colX = 0; colX < aNumCols; colX++) {
   121       var cell = document.createElement("TD", null);
   122       var text = document.createTextNode(genName());
   123       cell.appendChild(text);
   124       row.appendChild(cell);
   125 	}
   126 	table.appendChild(row);
   127   }
   128 }

mercurial