| Index: third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js b/third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js
|
| index 4017093594261f4b3c8394e76c4e44ad1e8fcab8..0897cae321bffb659b4de5912d59cfbaac2a8868 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js
|
| @@ -27,264 +27,296 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.VBox}
|
| - * @param {boolean} expandable
|
| - * @param {function()=} refreshCallback
|
| - * @param {function()=} selectedCallback
|
| + * @unrestricted
|
| */
|
| -WebInspector.CookiesTable = function(expandable, refreshCallback, selectedCallback)
|
| -{
|
| - WebInspector.VBox.call(this);
|
| +WebInspector.CookiesTable = class extends WebInspector.VBox {
|
| + /**
|
| + * @param {boolean} expandable
|
| + * @param {function()=} refreshCallback
|
| + * @param {function()=} selectedCallback
|
| + */
|
| + constructor(expandable, refreshCallback, selectedCallback) {
|
| + super();
|
|
|
| var readOnly = expandable;
|
| this._refreshCallback = refreshCallback;
|
|
|
| var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([
|
| - {id: "name", title: WebInspector.UIString("Name"), sortable: true, disclosure: expandable, sort: WebInspector.DataGrid.Order.Ascending, longText: true, weight: 24},
|
| - {id: "value", title: WebInspector.UIString("Value"), sortable: true, longText: true, weight: 34},
|
| - {id: "domain", title: WebInspector.UIString("Domain"), sortable: true, weight: 7},
|
| - {id: "path", title: WebInspector.UIString("Path"), sortable: true, weight: 7},
|
| - {id: "expires", title: WebInspector.UIString("Expires / Max-Age"), sortable: true, weight: 7},
|
| - {id: "size", title: WebInspector.UIString("Size"), sortable: true, align: WebInspector.DataGrid.Align.Right, weight: 7},
|
| - {id: "httpOnly", title: WebInspector.UIString("HTTP"), sortable: true, align: WebInspector.DataGrid.Align.Center, weight: 7},
|
| - {id: "secure", title: WebInspector.UIString("Secure"), sortable: true, align: WebInspector.DataGrid.Align.Center, weight: 7},
|
| - {id: "sameSite", title: WebInspector.UIString("SameSite"), sortable: true, align: WebInspector.DataGrid.Align.Center, weight: 7}
|
| + {
|
| + id: 'name',
|
| + title: WebInspector.UIString('Name'),
|
| + sortable: true,
|
| + disclosure: expandable,
|
| + sort: WebInspector.DataGrid.Order.Ascending,
|
| + longText: true,
|
| + weight: 24
|
| + },
|
| + {id: 'value', title: WebInspector.UIString('Value'), sortable: true, longText: true, weight: 34},
|
| + {id: 'domain', title: WebInspector.UIString('Domain'), sortable: true, weight: 7},
|
| + {id: 'path', title: WebInspector.UIString('Path'), sortable: true, weight: 7},
|
| + {id: 'expires', title: WebInspector.UIString('Expires / Max-Age'), sortable: true, weight: 7}, {
|
| + id: 'size',
|
| + title: WebInspector.UIString('Size'),
|
| + sortable: true,
|
| + align: WebInspector.DataGrid.Align.Right,
|
| + weight: 7
|
| + },
|
| + {
|
| + id: 'httpOnly',
|
| + title: WebInspector.UIString('HTTP'),
|
| + sortable: true,
|
| + align: WebInspector.DataGrid.Align.Center,
|
| + weight: 7
|
| + },
|
| + {
|
| + id: 'secure',
|
| + title: WebInspector.UIString('Secure'),
|
| + sortable: true,
|
| + align: WebInspector.DataGrid.Align.Center,
|
| + weight: 7
|
| + },
|
| + {
|
| + id: 'sameSite',
|
| + title: WebInspector.UIString('SameSite'),
|
| + sortable: true,
|
| + align: WebInspector.DataGrid.Align.Center,
|
| + weight: 7
|
| + }
|
| ]);
|
|
|
| if (readOnly) {
|
| - this._dataGrid = new WebInspector.DataGrid(columns);
|
| + this._dataGrid = new WebInspector.DataGrid(columns);
|
| } else {
|
| - this._dataGrid = new WebInspector.DataGrid(columns, undefined, this._onDeleteCookie.bind(this), refreshCallback);
|
| - this._dataGrid.setRowContextMenuCallback(this._onRowContextMenu.bind(this));
|
| + this._dataGrid = new WebInspector.DataGrid(columns, undefined, this._onDeleteCookie.bind(this), refreshCallback);
|
| + this._dataGrid.setRowContextMenuCallback(this._onRowContextMenu.bind(this));
|
| }
|
|
|
| - this._dataGrid.setName("cookiesTable");
|
| + this._dataGrid.setName('cookiesTable');
|
| this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._rebuildTable, this);
|
|
|
| if (selectedCallback)
|
| - this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, selectedCallback, this);
|
| + this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, selectedCallback, this);
|
|
|
| this._nextSelectedCookie = /** @type {?WebInspector.Cookie} */ (null);
|
|
|
| this._dataGrid.asWidget().show(this.element);
|
| this._data = [];
|
| -};
|
| + }
|
|
|
| -WebInspector.CookiesTable.prototype = {
|
| - /**
|
| - * @param {?string} domain
|
| - */
|
| - _clearAndRefresh: function(domain)
|
| - {
|
| - this.clear(domain);
|
| - this._refresh();
|
| - },
|
| + /**
|
| + * @param {?string} domain
|
| + */
|
| + _clearAndRefresh(domain) {
|
| + this.clear(domain);
|
| + this._refresh();
|
| + }
|
|
|
| - /**
|
| - * @param {!WebInspector.ContextMenu} contextMenu
|
| - * @param {!WebInspector.DataGridNode} node
|
| - */
|
| - _onRowContextMenu: function(contextMenu, node)
|
| - {
|
| - if (node === this._dataGrid.creationNode)
|
| - return;
|
| - var domain = node.cookie.domain();
|
| - if (domain)
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^all from \"%s\"", domain), this._clearAndRefresh.bind(this, domain));
|
| - contextMenu.appendItem(WebInspector.UIString.capitalize("Clear ^all"), this._clearAndRefresh.bind(this, null));
|
| - },
|
| + /**
|
| + * @param {!WebInspector.ContextMenu} contextMenu
|
| + * @param {!WebInspector.DataGridNode} node
|
| + */
|
| + _onRowContextMenu(contextMenu, node) {
|
| + if (node === this._dataGrid.creationNode)
|
| + return;
|
| + var domain = node.cookie.domain();
|
| + if (domain)
|
| + contextMenu.appendItem(
|
| + WebInspector.UIString.capitalize('Clear ^all from "%s"', domain), this._clearAndRefresh.bind(this, domain));
|
| + contextMenu.appendItem(WebInspector.UIString.capitalize('Clear ^all'), this._clearAndRefresh.bind(this, null));
|
| + }
|
|
|
| - /**
|
| - * @param {!Array.<!WebInspector.Cookie>} cookies
|
| - */
|
| - setCookies: function(cookies)
|
| - {
|
| - this.setCookieFolders([{cookies: cookies}]);
|
| - },
|
| + /**
|
| + * @param {!Array.<!WebInspector.Cookie>} cookies
|
| + */
|
| + setCookies(cookies) {
|
| + this.setCookieFolders([{cookies: cookies}]);
|
| + }
|
|
|
| - /**
|
| - * @param {!Array.<!{folderName: ?string, cookies: !Array.<!WebInspector.Cookie>}>} cookieFolders
|
| - */
|
| - setCookieFolders: function(cookieFolders)
|
| - {
|
| - this._data = cookieFolders;
|
| - this._rebuildTable();
|
| - },
|
| + /**
|
| + * @param {!Array.<!{folderName: ?string, cookies: !Array.<!WebInspector.Cookie>}>} cookieFolders
|
| + */
|
| + setCookieFolders(cookieFolders) {
|
| + this._data = cookieFolders;
|
| + this._rebuildTable();
|
| + }
|
|
|
| - /**
|
| - * @return {?WebInspector.Cookie}
|
| - */
|
| - selectedCookie: function()
|
| - {
|
| - var node = this._dataGrid.selectedNode;
|
| - return node ? node.cookie : null;
|
| - },
|
| + /**
|
| + * @return {?WebInspector.Cookie}
|
| + */
|
| + selectedCookie() {
|
| + var node = this._dataGrid.selectedNode;
|
| + return node ? node.cookie : null;
|
| + }
|
|
|
| - /**
|
| - * @param {?string=} domain
|
| - */
|
| - clear: function(domain)
|
| - {
|
| - for (var i = 0, length = this._data.length; i < length; ++i) {
|
| - var cookies = this._data[i].cookies;
|
| - for (var j = 0, cookieCount = cookies.length; j < cookieCount; ++j) {
|
| - if (!domain || cookies[j].domain() === domain)
|
| - cookies[j].remove();
|
| - }
|
| - }
|
| - },
|
| + /**
|
| + * @param {?string=} domain
|
| + */
|
| + clear(domain) {
|
| + for (var i = 0, length = this._data.length; i < length; ++i) {
|
| + var cookies = this._data[i].cookies;
|
| + for (var j = 0, cookieCount = cookies.length; j < cookieCount; ++j) {
|
| + if (!domain || cookies[j].domain() === domain)
|
| + cookies[j].remove();
|
| + }
|
| + }
|
| + }
|
|
|
| - _rebuildTable: function()
|
| - {
|
| - var selectedCookie = this._nextSelectedCookie || this.selectedCookie();
|
| - this._nextSelectedCookie = null;
|
| - this._dataGrid.rootNode().removeChildren();
|
| - for (var i = 0; i < this._data.length; ++i) {
|
| - var item = this._data[i];
|
| - if (item.folderName) {
|
| - var groupData = {name: item.folderName, value: "", domain: "", path: "", expires: "", size: this._totalSize(item.cookies), httpOnly: "", secure: "", sameSite: ""};
|
| - var groupNode = new WebInspector.DataGridNode(groupData);
|
| - groupNode.selectable = true;
|
| - this._dataGrid.rootNode().appendChild(groupNode);
|
| - groupNode.element().classList.add("row-group");
|
| - this._populateNode(groupNode, item.cookies, selectedCookie);
|
| - groupNode.expand();
|
| - } else
|
| - this._populateNode(this._dataGrid.rootNode(), item.cookies, selectedCookie);
|
| - }
|
| - },
|
| + _rebuildTable() {
|
| + var selectedCookie = this._nextSelectedCookie || this.selectedCookie();
|
| + this._nextSelectedCookie = null;
|
| + this._dataGrid.rootNode().removeChildren();
|
| + for (var i = 0; i < this._data.length; ++i) {
|
| + var item = this._data[i];
|
| + if (item.folderName) {
|
| + var groupData = {
|
| + name: item.folderName,
|
| + value: '',
|
| + domain: '',
|
| + path: '',
|
| + expires: '',
|
| + size: this._totalSize(item.cookies),
|
| + httpOnly: '',
|
| + secure: '',
|
| + sameSite: ''
|
| + };
|
| + var groupNode = new WebInspector.DataGridNode(groupData);
|
| + groupNode.selectable = true;
|
| + this._dataGrid.rootNode().appendChild(groupNode);
|
| + groupNode.element().classList.add('row-group');
|
| + this._populateNode(groupNode, item.cookies, selectedCookie);
|
| + groupNode.expand();
|
| + } else
|
| + this._populateNode(this._dataGrid.rootNode(), item.cookies, selectedCookie);
|
| + }
|
| + }
|
|
|
| - /**
|
| - * @param {!WebInspector.DataGridNode} parentNode
|
| - * @param {?Array.<!WebInspector.Cookie>} cookies
|
| - * @param {?WebInspector.Cookie} selectedCookie
|
| - */
|
| - _populateNode: function(parentNode, cookies, selectedCookie)
|
| - {
|
| - parentNode.removeChildren();
|
| - if (!cookies)
|
| - return;
|
| + /**
|
| + * @param {!WebInspector.DataGridNode} parentNode
|
| + * @param {?Array.<!WebInspector.Cookie>} cookies
|
| + * @param {?WebInspector.Cookie} selectedCookie
|
| + */
|
| + _populateNode(parentNode, cookies, selectedCookie) {
|
| + parentNode.removeChildren();
|
| + if (!cookies)
|
| + return;
|
| +
|
| + this._sortCookies(cookies);
|
| + for (var i = 0; i < cookies.length; ++i) {
|
| + var cookie = cookies[i];
|
| + var cookieNode = this._createGridNode(cookie);
|
| + parentNode.appendChild(cookieNode);
|
| + if (selectedCookie && selectedCookie.name() === cookie.name() && selectedCookie.domain() === cookie.domain() &&
|
| + selectedCookie.path() === cookie.path())
|
| + cookieNode.select();
|
| + }
|
| + }
|
|
|
| - this._sortCookies(cookies);
|
| - for (var i = 0; i < cookies.length; ++i) {
|
| - var cookie = cookies[i];
|
| - var cookieNode = this._createGridNode(cookie);
|
| - parentNode.appendChild(cookieNode);
|
| - if (selectedCookie && selectedCookie.name() === cookie.name() && selectedCookie.domain() === cookie.domain() && selectedCookie.path() === cookie.path())
|
| - cookieNode.select();
|
| - }
|
| - },
|
| + _totalSize(cookies) {
|
| + var totalSize = 0;
|
| + for (var i = 0; cookies && i < cookies.length; ++i)
|
| + totalSize += cookies[i].size();
|
| + return totalSize;
|
| + }
|
|
|
| - _totalSize: function(cookies)
|
| - {
|
| - var totalSize = 0;
|
| - for (var i = 0; cookies && i < cookies.length; ++i)
|
| - totalSize += cookies[i].size();
|
| - return totalSize;
|
| - },
|
| + /**
|
| + * @param {!Array.<!WebInspector.Cookie>} cookies
|
| + */
|
| + _sortCookies(cookies) {
|
| + var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1;
|
|
|
| /**
|
| - * @param {!Array.<!WebInspector.Cookie>} cookies
|
| + * @param {string} property
|
| + * @param {!WebInspector.Cookie} cookie1
|
| + * @param {!WebInspector.Cookie} cookie2
|
| */
|
| - _sortCookies: function(cookies)
|
| - {
|
| - var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1;
|
| -
|
| - function compareTo(getter, cookie1, cookie2)
|
| - {
|
| - return sortDirection * (getter.apply(cookie1) + "").compareTo(getter.apply(cookie2) + "");
|
| - }
|
| -
|
| - function numberCompare(getter, cookie1, cookie2)
|
| - {
|
| - return sortDirection * (getter.apply(cookie1) - getter.apply(cookie2));
|
| - }
|
| -
|
| - function expiresCompare(cookie1, cookie2)
|
| - {
|
| - if (cookie1.session() !== cookie2.session())
|
| - return sortDirection * (cookie1.session() ? 1 : -1);
|
| + function compareTo(property, cookie1, cookie2) {
|
| + return sortDirection *
|
| + (String(cookie1[property] || cookie1['name'])).compareTo(String(cookie2[property] || cookie2['name']));
|
| + }
|
|
|
| - if (cookie1.session())
|
| - return 0;
|
| + /**
|
| + * @param {!WebInspector.Cookie} cookie1
|
| + * @param {!WebInspector.Cookie} cookie2
|
| + */
|
| + function numberCompare(cookie1, cookie2) {
|
| + return sortDirection * (cookie1.size() - cookie2.size());
|
| + }
|
|
|
| - if (cookie1.maxAge() && cookie2.maxAge())
|
| - return sortDirection * (cookie1.maxAge() - cookie2.maxAge());
|
| - if (cookie1.expires() && cookie2.expires())
|
| - return sortDirection * (cookie1.expires() - cookie2.expires());
|
| - return sortDirection * (cookie1.expires() ? 1 : -1);
|
| - }
|
| + /**
|
| + * @param {!WebInspector.Cookie} cookie1
|
| + * @param {!WebInspector.Cookie} cookie2
|
| + */
|
| + function expiresCompare(cookie1, cookie2) {
|
| + if (cookie1.session() !== cookie2.session())
|
| + return sortDirection * (cookie1.session() ? 1 : -1);
|
|
|
| - var comparator;
|
| - switch (this._dataGrid.sortColumnId()) {
|
| - case "name": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.name); break;
|
| - case "value": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.value); break;
|
| - case "domain": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.domain); break;
|
| - case "path": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.path); break;
|
| - case "expires": comparator = expiresCompare; break;
|
| - case "size": comparator = numberCompare.bind(null, WebInspector.Cookie.prototype.size); break;
|
| - case "httpOnly": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.httpOnly); break;
|
| - case "secure": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.secure); break;
|
| - case "sameSite": comparator = compareTo.bind(null, WebInspector.Cookie.prototype.sameSite); break;
|
| - default: compareTo.bind(null, WebInspector.Cookie.prototype.name);
|
| - }
|
| + if (cookie1.session())
|
| + return 0;
|
|
|
| - cookies.sort(comparator);
|
| - },
|
| + if (cookie1.maxAge() && cookie2.maxAge())
|
| + return sortDirection * (cookie1.maxAge() - cookie2.maxAge());
|
| + if (cookie1.expires() && cookie2.expires())
|
| + return sortDirection * (cookie1.expires() - cookie2.expires());
|
| + return sortDirection * (cookie1.expires() ? 1 : -1);
|
| + }
|
|
|
| - /**
|
| - * @param {!WebInspector.Cookie} cookie
|
| - * @return {!WebInspector.DataGridNode}
|
| - */
|
| - _createGridNode: function(cookie)
|
| - {
|
| - var data = {};
|
| - data.name = cookie.name();
|
| - data.value = cookie.value();
|
| - if (cookie.type() === WebInspector.Cookie.Type.Request) {
|
| - data.domain = WebInspector.UIString("N/A");
|
| - data.path = WebInspector.UIString("N/A");
|
| - data.expires = WebInspector.UIString("N/A");
|
| - } else {
|
| - data.domain = cookie.domain() || "";
|
| - data.path = cookie.path() || "";
|
| - if (cookie.maxAge())
|
| - data.expires = Number.secondsToString(parseInt(cookie.maxAge(), 10));
|
| - else if (cookie.expires())
|
| - data.expires = new Date(cookie.expires()).toISOString();
|
| - else
|
| - data.expires = WebInspector.UIString("Session");
|
| - }
|
| - data.size = cookie.size();
|
| - const checkmark = "\u2713";
|
| - data.httpOnly = (cookie.httpOnly() ? checkmark : "");
|
| - data.secure = (cookie.secure() ? checkmark : "");
|
| - data.sameSite = cookie.sameSite() || "";
|
| + var comparator;
|
| + var columnId = this._dataGrid.sortColumnId() || 'name';
|
| + if (columnId === 'expires')
|
| + comparator = expiresCompare;
|
| + else if (columnId === 'size')
|
| + comparator = numberCompare;
|
| + else
|
| + comparator = compareTo.bind(null, columnId);
|
| + cookies.sort(comparator);
|
| + }
|
|
|
| - var node = new WebInspector.DataGridNode(data);
|
| - node.cookie = cookie;
|
| - node.selectable = true;
|
| - return node;
|
| - },
|
| + /**
|
| + * @param {!WebInspector.Cookie} cookie
|
| + * @return {!WebInspector.DataGridNode}
|
| + */
|
| + _createGridNode(cookie) {
|
| + var data = {};
|
| + data.name = cookie.name();
|
| + data.value = cookie.value();
|
| + if (cookie.type() === WebInspector.Cookie.Type.Request) {
|
| + data.domain = WebInspector.UIString('N/A');
|
| + data.path = WebInspector.UIString('N/A');
|
| + data.expires = WebInspector.UIString('N/A');
|
| + } else {
|
| + data.domain = cookie.domain() || '';
|
| + data.path = cookie.path() || '';
|
| + if (cookie.maxAge())
|
| + data.expires = Number.secondsToString(parseInt(cookie.maxAge(), 10));
|
| + else if (cookie.expires())
|
| + data.expires = new Date(cookie.expires()).toISOString();
|
| + else
|
| + data.expires = WebInspector.UIString('Session');
|
| + }
|
| + data.size = cookie.size();
|
| + const checkmark = '\u2713';
|
| + data.httpOnly = (cookie.httpOnly() ? checkmark : '');
|
| + data.secure = (cookie.secure() ? checkmark : '');
|
| + data.sameSite = cookie.sameSite() || '';
|
|
|
| - _onDeleteCookie: function(node)
|
| - {
|
| - var cookie = node.cookie;
|
| - var neighbour = node.traverseNextNode() || node.traversePreviousNode();
|
| - if (neighbour)
|
| - this._nextSelectedCookie = neighbour.cookie;
|
| - cookie.remove();
|
| - this._refresh();
|
| - },
|
| + var node = new WebInspector.DataGridNode(data);
|
| + node.cookie = cookie;
|
| + node.selectable = true;
|
| + return node;
|
| + }
|
|
|
| - _refresh: function()
|
| - {
|
| - if (this._refreshCallback)
|
| - this._refreshCallback();
|
| - },
|
| + _onDeleteCookie(node) {
|
| + var cookie = node.cookie;
|
| + var neighbour = node.traverseNextNode() || node.traversePreviousNode();
|
| + if (neighbour)
|
| + this._nextSelectedCookie = neighbour.cookie;
|
| + cookie.remove();
|
| + this._refresh();
|
| + }
|
|
|
| - __proto__: WebInspector.VBox.prototype
|
| + _refresh() {
|
| + if (this._refreshCallback)
|
| + this._refreshCallback();
|
| + }
|
| };
|
|
|