Bug 1694699 - Avoid unnecessary string->URI conversions r=rpl

Differential Revision: https://phabricator.services.mozilla.com/D106317
This commit is contained in:
Rob Wu 2021-02-26 21:34:54 +00:00
Родитель f6d52040b9
Коммит 43ff27ed9a
2 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -252,8 +252,7 @@ class TabsUpdateFilterEventManager extends EventManager {
return false;
}
if (filter.urls) {
// We check permission first because tab.uri is null if !hasTabPermission.
return tab.hasTabPermission && filter.urls.matches(tab.uri);
return filter.urls.matches(tab._uri) && tab.hasTabPermission;
}
return true;
}

Просмотреть файл

@ -200,7 +200,7 @@ class TabBase {
* @readonly
*/
get matchesHostPermission() {
return this.extension.allowedOrigins.matches(this._url);
return this.extension.allowedOrigins.matches(this._uri);
}
/**
@ -235,15 +235,12 @@ class TabBase {
}
/**
* @property {nsIURI | null} uri
* Returns the current URI of this tab if the extension has permission
* to read it, or null otherwise.
* @property {nsIURI} _uri
* Returns the current URI of this tab.
* @readonly
*/
get uri() {
if (this.hasTabPermission) {
return this.browser.currentURI;
}
get _uri() {
return this.browser.currentURI;
}
/**
@ -629,8 +626,8 @@ class TabBase {
if (!this.hasTabPermission) {
return false;
}
// Using _url and _title instead of url/title to avoid repeated permission checks.
if (queryInfo.url && !queryInfo.url.matches(this._url)) {
// Using _uri and _title instead of url/title to avoid repeated permission checks.
if (queryInfo.url && !queryInfo.url.matches(this._uri)) {
return false;
}
if (queryInfo.title && !queryInfo.title.matches(this._title)) {