зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290901 - [webext] Allow APIs implementation to return null when the API should not be injected in a context. r=aswan
needed to be able to return null when the registered schema API should not be available based on the context type instead of WebExtensions permissions. MozReview-Commit-ID: G8w8ZYzmA7S --HG-- extra : rebase_source : 7cacd2d5b5c0e1ef354e2cef19c7d809cc632470
This commit is contained in:
Родитель
cf2a1dcaeb
Коммит
aa6d7d1c94
|
@ -363,8 +363,17 @@ function findPathInObject(obj, path) {
|
|||
}, []);
|
||||
|
||||
for (let elt of path) {
|
||||
obj = obj[elt] || undefined;
|
||||
// If we get a null object before reaching the requested path
|
||||
// (e.g. the API object is returned only on particular kind of contexts instead
|
||||
// of based on WebExtensions permissions, like it happens for the devtools APIs),
|
||||
// stop searching and return undefined.
|
||||
if (!obj || !(elt in obj)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
obj = obj[elt];
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче