Commit 824f4907 authored by Kris Maglione's avatar Kris Maglione
Browse files

Bug 1524688: Part 1b - Support static JavaScript components in...

Bug 1524688: Part 1b - Support static JavaScript components in browser_all_files_referenced. r=mccr8

--HG--
extra : source : d5dca413e2da67db3f7d52aefc669dd5d62c1142
parent a34d453e
......@@ -643,6 +643,10 @@ add_task(async function checkAllTheFiles() {
// Wait for all manifest to be parsed
await throttledMapPromises(manifestURIs, parseManifest);
for (let jsm of Components.manager.getComponentJSMs()) {
gReferencesFromCode.set(jsm, null);
}
// manifest.json is a common name, it is used for WebExtension manifests
// but also for other things. To tell them apart, we have to actually
// read the contents. This will populate gExtensionRoots with all
......
......@@ -9,6 +9,7 @@
#include "mozilla/PerfectHash.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozJSComponentLoader.h"
#include "nsCOMPtr.h"
......@@ -17,6 +18,7 @@
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsString.h"
#include "nsStringEnumerator.h"
// Cleanup pollution from zipstruct.h
#undef UNSUPPORTED
......@@ -68,6 +70,10 @@ const StaticCategoryEntry gStaticCategoryEntries[] = {
//# @category_entries@
};
const StringOffset gComponentJSMs[] = {
//# @component_jsms@
};
/**
* Returns a nsCString corresponding to the given entry in the `gStrings` string
* table. The resulting nsCString points directly to static storage, and does
......@@ -268,6 +274,20 @@ nsCString StaticCategory::Name() const {
return false;
}
/* static */ already_AddRefed<nsIUTF8StringEnumerator>
StaticComponents::GetComponentJSMs() {
auto jsms = MakeUnique<nsTArray<nsCString>>(MOZ_ARRAY_LENGTH(gComponentJSMs));
for (const auto& entry : gComponentJSMs) {
jsms->AppendElement(GetString(entry));
}
nsCOMPtr<nsIUTF8StringEnumerator> result;
MOZ_ALWAYS_SUCCEEDS(NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(result),
jsms.release()));
return result.forget();
}
/* static */ void StaticComponents::Shutdown() {
CallUnloadFuncs();
}
......
......@@ -17,6 +17,7 @@
#include "StaticComponentData.h"
class nsIFactory;
class nsIUTF8StringEnumerator;
class nsISupports;
namespace mozilla {
......@@ -208,6 +209,8 @@ class StaticComponents final {
static bool InvalidateContractID(const nsACString& aContractID,
bool aInvalid = true);
static already_AddRefed<nsIUTF8StringEnumerator> GetComponentJSMs();
/**
* Calls any module unload from manifests whose components have been loaded.
*/
......
......@@ -567,6 +567,8 @@ def gen_substs(manifests):
contract_map = {}
categories = defaultdict(list)
jsms = set()
types = set()
for mod in modules:
......@@ -588,6 +590,9 @@ def gen_substs(manifests):
if mod.type and not mod.headers:
types.add(mod.type)
if mod.jsm:
jsms.add(mod.jsm)
cid_phf = PerfectHash(modules, PHF_SIZE,
key=lambda module: module.cid.bytes)
......@@ -608,6 +613,9 @@ def gen_substs(manifests):
gen_includes(substs, headers)
substs['component_jsms'] = '\n'.join(' %s,' % strings.entry_to_cxx(jsm)
for jsm in sorted(jsms)) + '\n'
substs['decls'] = gen_decls(types)
substs['constructors'] = gen_constructors(cid_phf.entries)
......
......@@ -2014,6 +2014,14 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) {
return rv;
}
NS_IMETHODIMP
nsComponentManagerImpl::GetComponentJSMs(nsIUTF8StringEnumerator** aJSMs) {
nsCOMPtr<nsIUTF8StringEnumerator> result = StaticComponents::GetComponentJSMs();
result.forget(aJSMs);
return NS_OK;
}
NS_IMETHODIMP
nsComponentManagerImpl::GetManifestLocations(nsIArray** aLocations) {
NS_ENSURE_ARG_POINTER(aLocations);
......
......@@ -12,6 +12,7 @@
interface nsIFile;
interface nsIFactory;
interface nsIArray;
interface nsIUTF8StringEnumerator;
[scriptable, uuid(d604ffc3-1ba3-4f6c-b65f-1ed4199364c3)]
interface nsIComponentManager : nsISupports
......@@ -96,6 +97,12 @@ interface nsIComponentManager : nsISupports
* Get an array of nsIURIs of all registered and builtin manifest locations.
*/
nsIArray getManifestLocations();
/**
* Returns a list of JSM URLs which are used to create components. This
* should only be used in automation.
*/
nsIUTF8StringEnumerator getComponentJSMs();
};
......
Supports Markdown
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