Commit bac84a74 authored by Harley Li's avatar Harley Li Committed by Commit Bot

[DevTools] Disable 'clear site data' button on error page

In Application's Clear Storage panel, when the current site is invalid,
e.g. localhost:5000 (no server running there), the 'clear site data'
button should be deactivated, and the subtitle for this panel should
not display the security origin address.

Component 'ParsedURL' has the ability to tell whether the url is valid.

Bug: 915703, 919857
Change-Id: I41f6079bbef299d284b36815d3888e3cec1e0050
Reviewed-on: https://chromium-review.googlesource.com/c/1447317Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Haihong Li (Harley) <hhli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628440}
parent 1d656f16
......@@ -117,7 +117,14 @@ Resources.ClearStorageView = class extends UI.ThrottledWidget {
* @param {string} url
*/
_updateOrigin(url) {
this._securityOrigin = new Common.ParsedURL(url).securityOrigin();
const parsedURL = new Common.ParsedURL(url);
if (!parsedURL.isValid) {
this._clearButton.disabled = true;
this._securityOrigin = '';
} else {
this._clearButton.disabled = false;
this._securityOrigin = parsedURL.securityOrigin();
}
this._reportView.setSubtitle(this._securityOrigin);
this.doUpdate();
}
......
......@@ -44,6 +44,28 @@ Parsing url: http://foo@example.com/foo/bar/baz.html?queryParam1=value1&queryPar
fragment: fragmentWith/Many//Slashes
folderPathComponents: /foo/bar
lastPathComponent: baz.html
Parsing url: ://
isValid: false
scheme:
user:
host:
port:
path: ://
queryParams:
fragment:
folderPathComponents: :/
lastPathComponent:
Parsing url:
isValid: false
scheme:
user:
host:
port:
path:
queryParams:
fragment:
folderPathComponents:
lastPathComponent:
Parsing url: http://[::]/?queryParam1=value1&queryParam2=value2#fragmentWith/Many//Slashes
isValid: true
scheme: http
......
......@@ -11,6 +11,8 @@
'http://user42:Alina-!$&@example.com/foo/bar.html?queryParam1=value1&queryParam2=value2#fragmentWith/Many//Slashes');
parseAndDumpURL(
'http://foo@example.com/foo/bar/baz.html?queryParam1=value1&queryParam2=value2#fragmentWith/Many//Slashes');
parseAndDumpURL('://');
parseAndDumpURL('');
// support IPv6 localhost
parseAndDumpURL('http://[::]/?queryParam1=value1&queryParam2=value2#fragmentWith/Many//Slashes');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment