Changeset 274593 in webkit


Ignore:
Timestamp:
Mar 17, 2021 2:59:47 PM (16 months ago)
Author:
Devin Rousso
Message:

Web Inspector: use native datetime-local picker for changing expires value in cookie popover
https://bugs.webkit.org/show_bug.cgi?id=209389

Reviewed by BJ Burg.

r259173 already made it so that the <input> for Expires used datetime-local, so nothing
needs to be changed to adopt that. We still want to keep the "input" event listener that
parses and validates the value (or placeholder) of the <input type="datetime-local">
because dates in the past should be considered invalid.

  • UserInterface/Views/CookiePopover.js:

(WI.CookiePopover.prototype.show): Add step = 1 so that the seconds field is shown.
(WI.CookiePopover.prototype.show.formatDate): Added.
(WI.CookiePopover.prototype.show.formatDate.pad): Added.

  • UserInterface/Views/CookiePopover.css: Remove the FIXME comment.
Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r274592 r274593  
     12021-03-17  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: use native datetime-local picker for changing `expires` value in cookie popover
     4        https://bugs.webkit.org/show_bug.cgi?id=209389
     5
     6        Reviewed by BJ Burg.
     7
     8        r259173 already made it so that the `<input>` for Expires used `datetime-local`, so nothing
     9        needs to be changed to adopt that. We still want to keep the `"input"` event listener that
     10        parses and validates the `value` (or `placeholder`) of the `<input type="datetime-local">`
     11        because dates in the past should be considered invalid.
     12
     13        * UserInterface/Views/CookiePopover.js:
     14        (WI.CookiePopover.prototype.show): Add `step = 1` so that the seconds field is shown.
     15        (WI.CookiePopover.prototype.show.formatDate): Added.
     16        (WI.CookiePopover.prototype.show.formatDate.pad): Added.
     17        * UserInterface/Views/CookiePopover.css: Remove the FIXME comment.
     18
    1192021-03-17  Razvan Caliman  <rcaliman@apple.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Views/CookiePopover.css

    r269166 r274593  
    4646}
    4747
    48 /* FIXME: <https://webkit.org/b/209389> Web Inspector: use native datetime-local picker for changing `expires` value in cookie popover */
    49 
    5048.popover .cookie-popover-content > table > tr > td > input:matches([type="text"], [type="datetime-local"]) {
    5149    width: 100%;
  • trunk/Source/WebInspectorUI/UserInterface/Views/CookiePopover.js

    r262848 r274593  
    108108        this._preferredEdges = preferredEdges;
    109109
     110        function formatDate(date) {
     111            function pad(number) {
     112                return String(number).padStart(2, "0");
     113            }
     114            return [
     115                date.getFullYear(),
     116                "-",
     117                pad(date.getMonth() + 1),
     118                "-",
     119                pad(date.getDate()),
     120                "T",
     121                pad(date.getHours()),
     122                ":",
     123                pad(date.getMinutes()),
     124                ":",
     125                pad(date.getSeconds()),
     126            ].join("");
     127        }
     128
    110129        let data = {};
    111130        if (cookie) {
     
    114133            data.domain = cookie.domain;
    115134            data.path = cookie.path;
    116             data.expires = (cookie.expires || this._defaultExpires()).toLocaleString();
     135            data.expires = formatDate(cookie.expires || this._defaultExpires());
    117136            data.session = cookie.session;
    118137            data.httpOnly = cookie.httpOnly;
     
    125144            data.domain = urlComponents.host;
    126145            data.path = urlComponents.path;
    127             data.expires = this._defaultExpires().toLocaleString();
     146            data.expires = formatDate(this._defaultExpires());
    128147            data.session = true;
    129148            data.httpOnly = false;
     
    197216        let expiresInputRow = createInputRow("expires", WI.unlocalizedString("Expires"), "datetime-local", data.expires);
    198217        this._expiresInputElement = expiresInputRow.inputElement;
     218        this._expiresInputElement.step = 1; // Causes the seconds field to be shown.
    199219        this._expiresInputElement.addEventListener("input", (event) => {
    200220            this._expiresInputElement.classList.toggle("invalid", isNaN(this._parseExpires()));
Note: See TracChangeset for help on using the changeset viewer.