Skip to content

Commit 19b9ec2

Browse files
committed
Bug 1916277 - Part 1: Add pref dom.multiple_import_maps.enabled. r=jonco
Add a pref to enable support for multiple import maps. Differential Revision: https://phabricator.services.mozilla.com/D278654
1 parent abe59b8 commit 19b9ec2

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

js/loader/ImportMap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ static bool GetOwnProperty(JSContext* aCx, Handle<JSObject*> aObj,
387387
return true;
388388
}
389389

390+
// static
391+
bool ImportMap::IsMultipleImportMapsSupported() {
392+
return NS_IsMainThread() &&
393+
mozilla::StaticPrefs::dom_multiple_import_maps_enabled();
394+
}
395+
390396
// https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
391397
// static
392398
UniquePtr<ImportMap> ImportMap::ParseString(

js/loader/ImportMap.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ class ImportMap {
7171
mScopes(std::move(aScopes)),
7272
mIntegrity(std::move(aIntegrity)) {}
7373

74+
/**
75+
* A helper function to get the "dom.multiple_import_maps.enabled" pref.
76+
* The pref's type is of non-atomic, which can be only accessed on the main
77+
* thread.
78+
* If this function is called from a non-main thread, it safely returns false.
79+
*/
80+
static bool IsMultipleImportMapsSupported();
81+
7482
/**
7583
* Parse the JSON string from the Import map script.
7684
* This function will throw a TypeError if there's any invalid key or value in

modules/libpref/init/StaticPrefList.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3766,6 +3766,12 @@
37663766
value: true
37673767
mirror: always
37683768

3769+
# Enable mutiple import maps.
3770+
- name: dom.multiple_import_maps.enabled
3771+
type: bool
3772+
value: false
3773+
mirror: always
3774+
37693775
# Limit of location change caused by content scripts in a time span per
37703776
# BrowsingContext. This includes calls to History and Location APIs.
37713777
- name: dom.navigation.navigationRateLimit.count

0 commit comments

Comments
 (0)