mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1461278
- Print a note to the web console when a web site is using shadow DOM (v1), preffed off by default, r=emilio
This commit is contained in:
parent
1b656c34aa
commit
20c34cefa0
@ -14,6 +14,7 @@
|
||||
|
||||
#include "AnimationCommon.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/dom/Animation.h"
|
||||
#include "mozilla/dom/Attr.h"
|
||||
#include "mozilla/dom/Flex.h"
|
||||
@ -1247,6 +1248,10 @@ Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
|
||||
|
||||
shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc());
|
||||
|
||||
if (StaticPrefs::dom_webcomponents_shadowdom_report_usage()) {
|
||||
OwnerDoc()->ReportShadowDOMUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. Set context object’s shadow root to shadow.
|
||||
*/
|
||||
|
@ -1456,6 +1456,7 @@ nsIDocument::nsIDocument()
|
||||
mWidthStrEmpty(false),
|
||||
mParserAborted(false),
|
||||
mReportedUseCounters(false),
|
||||
mHasReportedShadowDOMUsage(false),
|
||||
#ifdef DEBUG
|
||||
mWillReparent(false),
|
||||
#endif
|
||||
@ -13220,3 +13221,27 @@ nsIDocument::ModuleScriptsEnabled()
|
||||
|
||||
return nsContentUtils::IsChromeDoc(this) || sEnabledForContent;
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::ReportShadowDOMUsage()
|
||||
{
|
||||
if (mHasReportedShadowDOMUsage) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDocument* topLevel = GetTopLevelContentDocument();
|
||||
if (topLevel && !topLevel->mHasReportedShadowDOMUsage) {
|
||||
topLevel->mHasReportedShadowDOMUsage = true;
|
||||
nsString uri;
|
||||
Unused << topLevel->GetDocumentURI(uri);
|
||||
if (!uri.IsEmpty()) {
|
||||
nsAutoString msg = NS_LITERAL_STRING("Shadow DOM used in [") + uri +
|
||||
NS_LITERAL_STRING("] or in some of its subdocuments.");
|
||||
nsContentUtils::ReportToConsoleNonLocalized(msg, nsIScriptError::infoFlag,
|
||||
NS_LITERAL_CSTRING("DOM"),
|
||||
topLevel);
|
||||
}
|
||||
}
|
||||
|
||||
mHasReportedShadowDOMUsage = true;
|
||||
}
|
||||
|
@ -3536,6 +3536,8 @@ public:
|
||||
*/
|
||||
nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const;
|
||||
|
||||
void ReportShadowDOMUsage();
|
||||
|
||||
protected:
|
||||
already_AddRefed<nsIPrincipal> MaybeDowngradePrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
@ -4052,6 +4054,8 @@ protected:
|
||||
// that we only report them once for the document.
|
||||
bool mReportedUseCounters: 1;
|
||||
|
||||
bool mHasReportedShadowDOMUsage: 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
public:
|
||||
bool mWillReparent: 1;
|
||||
|
@ -87,6 +87,16 @@ VARCACHE_PREF(
|
||||
bool, false
|
||||
)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// DOM prefs
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
VARCACHE_PREF(
|
||||
"dom.webcomponents.shadowdom.report_usage",
|
||||
dom_webcomponents_shadowdom_report_usage,
|
||||
bool, false
|
||||
)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Full-screen prefs
|
||||
//---------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user