зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1035091)
a=backout Backed out changeset 1fc07bdd9aa8 (bug 1035091) Backed out changeset f6e98029d1cb (bug 1035091) --HG-- rename : layout/style/test/chrome/test_moz_document_matching.html => layout/style/test/chrome/test_moz_document_rules.html rename : layout/style/test/chrome/test_moz_document_nesting.html => layout/style/test/test_bug511909.html rename : layout/style/test/chrome/test_moz_document_serialization.html => layout/style/test/test_rule_serialization.html
This commit is contained in:
Родитель
92cc8ece64
Коммит
53368e989a
|
@ -4409,8 +4409,7 @@ FindSheet(const nsCOMArray<nsIStyleSheet>& aSheets, nsIURI* aSheetURI)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI)
|
||||
nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI)
|
||||
{
|
||||
NS_PRECONDITION(aSheetURI, "null arg");
|
||||
|
||||
|
@ -4419,29 +4418,11 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Loading the sheet sync.
|
||||
nsRefPtr<css::Loader> loader = new css::Loader();
|
||||
|
||||
css::SheetParsingMode parsingMode;
|
||||
switch (aType) {
|
||||
case nsIDocument::eAgentSheet:
|
||||
parsingMode = css::eAgentSheetFeatures;
|
||||
break;
|
||||
|
||||
case nsIDocument::eUserSheet:
|
||||
parsingMode = css::eUserSheetFeatures;
|
||||
break;
|
||||
|
||||
case nsIDocument::eAuthorSheet:
|
||||
parsingMode = css::eAuthorSheetFeatures;
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("impossible value for aType");
|
||||
}
|
||||
nsRefPtr<mozilla::css::Loader> loader = new mozilla::css::Loader();
|
||||
|
||||
nsRefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, aType == eAgentSheet,
|
||||
true, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
sheet->SetOwningDocument(this);
|
||||
|
@ -9954,10 +9935,7 @@ nsresult
|
|||
nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
CSSStyleSheet** sheet)
|
||||
{
|
||||
css::SheetParsingMode mode =
|
||||
isAgentSheet ? css::eAgentSheetFeatures
|
||||
: css::eAuthorSheetFeatures;
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, sheet);
|
||||
return CSSLoader()->LoadSheetSync(uri, isAgentSheet, isAgentSheet, sheet);
|
||||
}
|
||||
|
||||
class nsDelayedEventDispatcher : public nsRunnable
|
||||
|
|
|
@ -1103,8 +1103,7 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal,
|
|||
// Create the CSS parser, and parse the CSS text.
|
||||
nsCSSParser parser(nullptr, sheet);
|
||||
rv = parser.ParseSheet(aOriginal, aDocument->GetDocumentURI(), aBaseURI,
|
||||
aDocument->NodePrincipal(), 0,
|
||||
mozilla::css::eAuthorSheetFeatures);
|
||||
aDocument->NodePrincipal(), 0, false);
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
// Mark the sheet as complete.
|
||||
MOZ_ASSERT(!sheet->IsModified(),
|
||||
|
|
|
@ -169,4 +169,3 @@ PEExpectedVariableNameEOF=identifier for variable name
|
|||
PEExpectedVariableName=Expected identifier for variable name but found '%1$S'.
|
||||
PEExpectedVariableFallback=Expected variable reference fallback after ','.
|
||||
PEExpectedVariableCommaOrCloseParen=Expected ',' or ')' after variable name in variable reference but found '%1$S'.
|
||||
PEMozDocumentRuleNotAllowed=@-moz-document rules may only be used in user style sheets.
|
||||
|
|
|
@ -148,9 +148,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
|
|||
NS_NewURI(getter_AddRefs(uri), spec);
|
||||
if (uri) {
|
||||
nsRefPtr<CSSStyleSheet> cssSheet;
|
||||
cssLoader->LoadSheetSync(uri,
|
||||
mozilla::css::eAgentSheetFeatures,
|
||||
true, getter_AddRefs(cssSheet));
|
||||
cssLoader->LoadSheetSync(uri, true, true, getter_AddRefs(cssSheet));
|
||||
if (cssSheet) {
|
||||
EnsureOnDemandBuiltInUASheet(cssSheet);
|
||||
}
|
||||
|
|
|
@ -2840,8 +2840,7 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
|
|||
nsRefPtr<CSSStyleSheet> sheet;
|
||||
// Editor override style sheets may want to style Gecko anonymous boxes
|
||||
rv = ps->GetDocument()->CSSLoader()->
|
||||
LoadSheetSync(uaURI, mozilla::css::eAgentSheetFeatures, true,
|
||||
getter_AddRefs(sheet));
|
||||
LoadSheetSync(uaURI, true, true, getter_AddRefs(sheet));
|
||||
|
||||
// Synchronous loads should ALWAYS return completed
|
||||
NS_ENSURE_TRUE(sheet, NS_ERROR_NULL_POINTER);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=520189
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=520182
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 520189</title>
|
||||
<title>Test for Bug 520182</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
@ -79,7 +79,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520189
|
|||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 520189 **/
|
||||
/** Test for Bug 520182 **/
|
||||
|
||||
const dataPayload = "foo<iframe src=\"data:text/html,bar\"></iframe>baz";
|
||||
const jsPayload = "foo<iframe src=\"javascript:void('bar');\"></iframe>baz";
|
||||
|
@ -421,21 +421,13 @@ var tests = [
|
|||
isIFrame: true,
|
||||
payload: invalidStyle8Payload,
|
||||
rootElement() { return document.getElementById("ss").contentDocument.documentElement; },
|
||||
// The sanitizer currently doesn't discard unrecognized rules when
|
||||
// that would make the sheet completely empty (see bug 1177546).
|
||||
// This is harmless, since @-moz-document is inoperative in author
|
||||
// style sheets (see bug 1035091).
|
||||
checkResult(html) { todo_is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
checkResult(html) { is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
},
|
||||
{
|
||||
id: "tt",
|
||||
payload: invalidStyle8Payload,
|
||||
rootElement() { return document.getElementById("tt"); },
|
||||
// The sanitizer currently doesn't discard unrecognized rules when
|
||||
// that would make the sheet completely empty (see bug 1177546).
|
||||
// This is harmless, since @-moz-document is inoperative in author
|
||||
// style sheets (see bug 1035091).
|
||||
checkResult(html) { todo_is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
checkResult(html) { is(html.indexOf("@-moz-document"), -1, "Should not have retained the @-moz-document rule"); },
|
||||
},
|
||||
{
|
||||
id: "uu",
|
||||
|
|
|
@ -180,32 +180,17 @@ nsresult
|
|||
nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
uint32_t aSheetType)
|
||||
{
|
||||
NS_ENSURE_ARG(aSheetType == AGENT_SHEET ||
|
||||
aSheetType == USER_SHEET ||
|
||||
aSheetType == AUTHOR_SHEET);
|
||||
NS_ENSURE_ARG_POINTER(aSheetURI);
|
||||
|
||||
css::SheetParsingMode parsingMode;
|
||||
switch (aSheetType) {
|
||||
case AGENT_SHEET:
|
||||
parsingMode = css::eAgentSheetFeatures;
|
||||
break;
|
||||
|
||||
case USER_SHEET:
|
||||
parsingMode = css::eUserSheetFeatures;
|
||||
break;
|
||||
|
||||
case AUTHOR_SHEET:
|
||||
parsingMode = css::eAuthorSheetFeatures;
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_WARNING("invalid sheet type argument");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsRefPtr<css::Loader> loader = new css::Loader();
|
||||
|
||||
nsRefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
// Allow UA sheets, but not user sheets, to use unsafe rules
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET,
|
||||
true, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mSheets[aSheetType].AppendObject(sheet)) {
|
||||
|
@ -234,32 +219,18 @@ NS_IMETHODIMP
|
|||
nsStyleSheetService::PreloadSheet(nsIURI *aSheetURI, uint32_t aSheetType,
|
||||
nsIDOMStyleSheet **aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "Null out param");
|
||||
NS_ENSURE_ARG(aSheetType == AGENT_SHEET ||
|
||||
aSheetType == USER_SHEET ||
|
||||
aSheetType == AUTHOR_SHEET);
|
||||
NS_ENSURE_ARG_POINTER(aSheetURI);
|
||||
css::SheetParsingMode parsingMode;
|
||||
switch (aSheetType) {
|
||||
case AGENT_SHEET:
|
||||
parsingMode = css::eAgentSheetFeatures;
|
||||
break;
|
||||
|
||||
case USER_SHEET:
|
||||
parsingMode = css::eUserSheetFeatures;
|
||||
break;
|
||||
|
||||
case AUTHOR_SHEET:
|
||||
parsingMode = css::eAuthorSheetFeatures;
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_WARNING("invalid sheet type argument");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
NS_PRECONDITION(aSheet, "Null out param");
|
||||
|
||||
nsRefPtr<css::Loader> loader = new css::Loader();
|
||||
|
||||
// Allow UA sheets, but not user sheets, to use unsafe rules
|
||||
nsRefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, aSheetType == AGENT_SHEET,
|
||||
true, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
sheet.forget(aSheet);
|
||||
return NS_OK;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
== scoped-style-media.html scoped-style-media-ref.html
|
||||
== scoped-style-namespace.html scoped-style-namespace-ref.html
|
||||
== scoped-style-charset.html scoped-style-charset-ref.html
|
||||
== scoped-style-document.html scoped-style-document-ref.html
|
||||
HTTP(..) == scoped-style-font-face.html scoped-style-font-face-ref.html
|
||||
== scoped-style-keyframes.html scoped-style-keyframes-ref.html
|
||||
== scoped-style-supports.html scoped-style-supports-ref.html
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>First</p>
|
||||
<p style="color: blue">Second</p>
|
||||
<p>Third</p>
|
||||
</body>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>First</p>
|
||||
<p>
|
||||
<style scoped>
|
||||
@-moz-document regexp("^.*scoped-style-document\\.html$") {
|
||||
p { color: blue }
|
||||
}
|
||||
</style>
|
||||
Second
|
||||
</p>
|
||||
<p>Third</p>
|
||||
</body>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>CSS Test: A nested @supports rule with valid syntax and a passing condition must apply rules inside it</title>
|
||||
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-document" />
|
||||
<meta name="flags" content="" />
|
||||
<meta name="assert" content="An outer @document rule with an inner @supports rule must apply the rules inside the @supports only if both the @supports and @document conditions pass."/>
|
||||
<link rel="match" href="support/pass.xht" />
|
||||
<style type="text/css"><![CDATA[
|
||||
@-moz-document url-prefix("") {
|
||||
@supports (color: green) {
|
||||
html { background-color: green }
|
||||
}
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>CSS Test: A nested @supports rule with valid syntax and a passing condition must apply rules inside it</title>
|
||||
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
|
||||
<link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
|
||||
<meta name="flags" content="" />
|
||||
<meta name="assert" content="An inner @document rule with an outer @supports rule must apply the rules inside the @document only if both the @supports and @document conditions pass."/>
|
||||
<link rel="match" href="support/pass.xht" />
|
||||
<style type="text/css"><![CDATA[
|
||||
@supports (color: green) {
|
||||
@-moz-document url-prefix("") {
|
||||
html { background-color: green }
|
||||
}
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -24,6 +24,8 @@
|
|||
== css-supports-024.xht support/pass.xht
|
||||
== css-supports-025.xht support/pass.xht
|
||||
== css-supports-026.xht support/pass.xht
|
||||
== css-supports-027.xht support/pass.xht
|
||||
== css-supports-028.xht support/pass.xht
|
||||
== css-supports-029.xht support/pass.xht
|
||||
== css-supports-030.xht support/pass.xht
|
||||
== css-supports-031.xht support/pass.xht
|
||||
|
|
|
@ -2309,14 +2309,11 @@ CSSStyleSheet::ParseSheet(const nsAString& aInput)
|
|||
mInner->mNameSpaceMap = nullptr;
|
||||
|
||||
// allow unsafe rules if the style sheet's principal is the system principal
|
||||
css::SheetParsingMode parsingMode =
|
||||
nsContentUtils::IsSystemPrincipal(mInner->mPrincipal)
|
||||
? css::eAgentSheetFeatures
|
||||
: css::eAuthorSheetFeatures;
|
||||
bool allowUnsafeRules = nsContentUtils::IsSystemPrincipal(mInner->mPrincipal);
|
||||
|
||||
nsCSSParser parser(loader, this);
|
||||
nsresult rv = parser.ParseSheet(aInput, mInner->mSheetURI, mInner->mBaseURI,
|
||||
mInner->mPrincipal, 1, parsingMode);
|
||||
mInner->mPrincipal, 1, allowUnsafeRules);
|
||||
DidDirty(); // we are always 'dirty' here since we always remove rules first
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -104,12 +104,6 @@ namespace css {
|
|||
* Data needed to properly load a stylesheet *
|
||||
*********************************************/
|
||||
|
||||
static_assert(eAuthorSheetFeatures == 0 &&
|
||||
eUserSheetFeatures == 1 &&
|
||||
eAgentSheetFeatures == 2,
|
||||
"sheet parsing mode constants won't fit "
|
||||
"in SheetLoadData::mParsingMode");
|
||||
|
||||
class SheetLoadData final : public nsIRunnable,
|
||||
public nsIUnicharStreamLoaderObserver,
|
||||
public nsIThreadObserver
|
||||
|
@ -143,7 +137,7 @@ public:
|
|||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
bool aSyncLoad,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aAllowUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
const nsCString& aCharset,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
|
@ -221,12 +215,9 @@ public:
|
|||
// created.
|
||||
bool mWasAlternate : 1;
|
||||
|
||||
// mParsingMode controls access to nonstandard style constructs that
|
||||
// are not safe for use on the public Web but necessary in UA sheets
|
||||
// and/or useful in user sheets. The only values stored in this
|
||||
// field are 0, 1, and 2; three bits are allocated to avoid issues
|
||||
// should the enum type be signed.
|
||||
SheetParsingMode mParsingMode : 3;
|
||||
// mAllowUnsafeRules is true if we should allow unsafe rules to be parsed
|
||||
// in the loaded sheet.
|
||||
bool mAllowUnsafeRules : 1;
|
||||
|
||||
// mUseSystemPrincipal is true if the system principal should be used for
|
||||
// this sheet, no matter what the channel principal is. Only true for sync
|
||||
|
@ -342,7 +333,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
mIsCancelled(false),
|
||||
mMustNotify(false),
|
||||
mWasAlternate(aIsAlternate),
|
||||
mParsingMode(eAuthorSheetFeatures),
|
||||
mAllowUnsafeRules(false),
|
||||
mUseSystemPrincipal(false),
|
||||
mSheetAlreadyComplete(false),
|
||||
mOwningElement(aOwningElement),
|
||||
|
@ -373,7 +364,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
mIsCancelled(false),
|
||||
mMustNotify(false),
|
||||
mWasAlternate(false),
|
||||
mParsingMode(eAuthorSheetFeatures),
|
||||
mAllowUnsafeRules(false),
|
||||
mUseSystemPrincipal(false),
|
||||
mSheetAlreadyComplete(false),
|
||||
mOwningElement(nullptr),
|
||||
|
@ -385,7 +376,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
if (mParentData) {
|
||||
mSyncLoad = mParentData->mSyncLoad;
|
||||
mIsNonDocumentSheet = mParentData->mIsNonDocumentSheet;
|
||||
mParsingMode = mParentData->mParsingMode;
|
||||
mAllowUnsafeRules = mParentData->mAllowUnsafeRules;
|
||||
mUseSystemPrincipal = mParentData->mUseSystemPrincipal;
|
||||
++(mParentData->mPendingChildren);
|
||||
}
|
||||
|
@ -398,7 +389,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
bool aSyncLoad,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aAllowUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
const nsCString& aCharset,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
|
@ -416,7 +407,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
mIsCancelled(false),
|
||||
mMustNotify(false),
|
||||
mWasAlternate(false),
|
||||
mParsingMode(aParsingMode),
|
||||
mAllowUnsafeRules(aAllowUnsafeRules),
|
||||
mUseSystemPrincipal(aUseSystemPrincipal),
|
||||
mSheetAlreadyComplete(false),
|
||||
mOwningElement(nullptr),
|
||||
|
@ -426,10 +417,6 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||
mCharsetHint(aCharset)
|
||||
{
|
||||
NS_PRECONDITION(mLoader, "Must have a loader!");
|
||||
NS_PRECONDITION(aParsingMode == eAuthorSheetFeatures ||
|
||||
aParsingMode == eUserSheetFeatures ||
|
||||
aParsingMode == eAgentSheetFeatures,
|
||||
"Unrecognized sheet parsing mode");
|
||||
|
||||
NS_POSTCONDITION(!mUseSystemPrincipal || mSyncLoad,
|
||||
"Shouldn't use system principal for async loads");
|
||||
|
@ -1758,7 +1745,7 @@ Loader::ParseSheet(const nsAString& aInput,
|
|||
nsresult rv = parser.ParseSheet(aInput, sheetURI, baseURI,
|
||||
aLoadData->mSheet->Principal(),
|
||||
aLoadData->mLineNumber,
|
||||
aLoadData->mParsingMode);
|
||||
aLoadData->mAllowUnsafeRules);
|
||||
mParsingDatas.RemoveElementAt(mParsingDatas.Length() - 1);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -2266,13 +2253,12 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
|
|||
}
|
||||
|
||||
nsresult
|
||||
Loader::LoadSheetSync(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
Loader::LoadSheetSync(nsIURI* aURL, bool aAllowUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
CSSStyleSheet** aSheet)
|
||||
{
|
||||
LOG(("css::Loader::LoadSheetSync"));
|
||||
return InternalLoadNonDocumentSheet(aURL, aParsingMode,
|
||||
return InternalLoadNonDocumentSheet(aURL, aAllowUnsafeRules,
|
||||
aUseSystemPrincipal, nullptr,
|
||||
EmptyCString(), aSheet, nullptr);
|
||||
}
|
||||
|
@ -2286,7 +2272,7 @@ Loader::LoadSheet(nsIURI* aURL,
|
|||
{
|
||||
LOG(("css::Loader::LoadSheet(aURL, aObserver, aSheet) api call"));
|
||||
NS_PRECONDITION(aSheet, "aSheet is null");
|
||||
return InternalLoadNonDocumentSheet(aURL, eAuthorSheetFeatures, false,
|
||||
return InternalLoadNonDocumentSheet(aURL, false, false,
|
||||
aOriginPrincipal, aCharset,
|
||||
aSheet, aObserver);
|
||||
}
|
||||
|
@ -2301,7 +2287,7 @@ Loader::LoadSheet(nsIURI* aURL,
|
|||
const nsAString& aIntegrity)
|
||||
{
|
||||
LOG(("css::Loader::LoadSheet(aURL, aObserver) api call"));
|
||||
return InternalLoadNonDocumentSheet(aURL, eAuthorSheetFeatures, false,
|
||||
return InternalLoadNonDocumentSheet(aURL, false, false,
|
||||
aOriginPrincipal, aCharset,
|
||||
nullptr, aObserver, aCORSMode,
|
||||
aReferrerPolicy, aIntegrity);
|
||||
|
@ -2309,7 +2295,7 @@ Loader::LoadSheet(nsIURI* aURL,
|
|||
|
||||
nsresult
|
||||
Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aAllowUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
|
@ -2366,7 +2352,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
|||
}
|
||||
|
||||
SheetLoadData* data =
|
||||
new SheetLoadData(this, aURL, sheet, syncLoad, aParsingMode,
|
||||
new SheetLoadData(this, aURL, sheet, syncLoad, aAllowUnsafeRules,
|
||||
aUseSystemPrincipal, aCharset, aObserver,
|
||||
aOriginPrincipal, mDocument);
|
||||
|
||||
|
|
|
@ -142,33 +142,6 @@ enum StyleSheetState {
|
|||
eSheetComplete
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum defining the mode in which a sheet is to be parsed. This is
|
||||
* usually, but not always, the same as the cascade level at which the
|
||||
* sheet will apply (see nsStyleSet.h). Most of the Loader APIs only
|
||||
* support loading of author sheets.
|
||||
*
|
||||
* Author sheets are the normal case: styles embedded in or linked
|
||||
* from HTML pages. They are also the most restricted.
|
||||
*
|
||||
* User sheets can do anything author sheets can do, and also get
|
||||
* access to a few CSS extensions that are not yet suitable for
|
||||
* exposure on the public Web, but are very useful for expressing
|
||||
* user style overrides, such as @-moz-document rules.
|
||||
*
|
||||
* Agent sheets have access to all author- and user-sheet features
|
||||
* plus more extensions that are necessary for internal use but,
|
||||
* again, not yet suitable for exposure on the public Web. Some of
|
||||
* these are outright unsafe to expose; in particular, incorrect
|
||||
* styling of anonymous box pseudo-elements can violate layout
|
||||
* invariants.
|
||||
*/
|
||||
enum SheetParsingMode {
|
||||
eAuthorSheetFeatures = 0,
|
||||
eUserSheetFeatures,
|
||||
eAgentSheetFeatures
|
||||
};
|
||||
|
||||
class Loader final {
|
||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
||||
|
||||
|
@ -283,8 +256,13 @@ public:
|
|||
* method can be used to load sheets not associated with a document.
|
||||
*
|
||||
* @param aURL the URL of the sheet to load
|
||||
* @param aParsingMode the mode in which to parse the sheet
|
||||
* (see comments at enum SheetParsingMode, above).
|
||||
* @param aEnableUnsafeRules whether unsafe rules are enabled for this
|
||||
* sheet load
|
||||
* Unsafe rules are rules that can violate key Gecko invariants if misused.
|
||||
* In particular, most anonymous box pseudoelements must be very carefully
|
||||
* styled or we will have severe problems. Therefore unsafe rules should
|
||||
* never be enabled for stylesheets controlled by untrusted sites; preferably
|
||||
* unsafe rules should only be enabled for agent sheets.
|
||||
* @param aUseSystemPrincipal if true, give the resulting sheet the system
|
||||
* principal no matter where it's being loaded from.
|
||||
* @param [out] aSheet the loaded, complete sheet.
|
||||
|
@ -297,25 +275,22 @@ public:
|
|||
* whether the data could be parsed as CSS and doesn't indicate anything
|
||||
* about the status of child sheets of the returned sheet.
|
||||
*/
|
||||
nsresult LoadSheetSync(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
nsresult LoadSheetSync(nsIURI* aURL, bool aEnableUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
CSSStyleSheet** aSheet);
|
||||
|
||||
/**
|
||||
* As above, but defaults aParsingMode to eAuthorSheetFeatures and
|
||||
* aUseSystemPrincipal to false.
|
||||
* As above, but aUseSystemPrincipal and aEnableUnsafeRules are assumed false.
|
||||
*/
|
||||
nsresult LoadSheetSync(nsIURI* aURL, CSSStyleSheet** aSheet) {
|
||||
return LoadSheetSync(aURL, eAuthorSheetFeatures, false, aSheet);
|
||||
return LoadSheetSync(aURL, false, false, aSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously load the stylesheet at aURL. If a successful result is
|
||||
* returned, aObserver is guaranteed to be notified asynchronously once the
|
||||
* sheet is loaded and marked complete. This method can be used to load
|
||||
* sheets not associated with a document. This method cannot be used to
|
||||
* load user or agent sheets.
|
||||
* sheets not associated with a document.
|
||||
*
|
||||
* @param aURL the URL of the sheet to load
|
||||
* @param aOriginPrincipal the principal to use for security checks. This
|
||||
|
@ -471,7 +446,7 @@ private:
|
|||
ImportRule* aParentRule);
|
||||
|
||||
nsresult InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aAllowUnsafeRules,
|
||||
bool aUseSystemPrincipal,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
@import # { }
|
||||
@namespace # { }
|
||||
@media # { }
|
||||
@-moz-document # { }
|
||||
@font-face # { }
|
||||
@page # { }
|
||||
@-non-mozilla # { }
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
|
||||
<link rel="stylesheet" href="data:text/css,@-moz-document domain(example.com) {}';">
|
||||
<script>
|
||||
// Force a unique inner for the second linked sheet
|
||||
document.styleSheets[1].cssRules[0];
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
|
|
@ -49,7 +49,9 @@ load 478321-1.xhtml
|
|||
load 512851-1.xhtml
|
||||
load 539613-1.xhtml
|
||||
load 588627-1.html
|
||||
skip load long-url-list-stack-overflow.html # skipped due to being slow (bug 477490)
|
||||
load 495269-1.html
|
||||
load 495269-2.html
|
||||
load 498036-1.html
|
||||
load 509155-1.html
|
||||
load 509156-1.html
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style id="s"></style>
|
||||
<script type="text/javascript">
|
||||
|
||||
// Duplicates the string 2^n times
|
||||
function exp(s, n)
|
||||
{
|
||||
for (var i = 0; i < n; ++i)
|
||||
s += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
var stylesheet = "@-moz-document url(http://www.w3.org/)" + exp(", url-prefix(file:///)", 20) + " { }";
|
||||
document.getElementById("s").textContent = stylesheet;
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div></div>
|
||||
</body>
|
||||
</html>
|
|
@ -105,12 +105,6 @@ struct CSSParserInputState {
|
|||
bool mHavePushBack;
|
||||
};
|
||||
|
||||
static_assert(eAuthorSheetFeatures == 0 &&
|
||||
eUserSheetFeatures == 1 &&
|
||||
eAgentSheetFeatures == 2,
|
||||
"sheet parsing mode constants won't fit "
|
||||
"in CSSParserImpl::mParsingMode");
|
||||
|
||||
// Your basic top-down recursive descent style parser
|
||||
// The exposed methods and members of this class are precisely those
|
||||
// needed by nsCSSParser, far below.
|
||||
|
@ -135,7 +129,7 @@ public:
|
|||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber,
|
||||
SheetParsingMode aParsingMode);
|
||||
bool aAllowUnsafeRules);
|
||||
|
||||
nsresult ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aDocURL,
|
||||
|
@ -319,20 +313,12 @@ public:
|
|||
uint32_t aLineNumber,
|
||||
uint32_t aLineOffset);
|
||||
|
||||
bool AgentRulesEnabled() const {
|
||||
return mParsingMode == eAgentSheetFeatures;
|
||||
}
|
||||
bool UserRulesEnabled() const {
|
||||
return mParsingMode == eAgentSheetFeatures ||
|
||||
mParsingMode == eUserSheetFeatures;
|
||||
}
|
||||
|
||||
nsCSSProps::EnabledState PropertyEnabledState() const {
|
||||
static_assert(nsCSSProps::eEnabledForAllContent == 0,
|
||||
"nsCSSProps::eEnabledForAllContent should be zero for "
|
||||
"this bitfield to work");
|
||||
nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent;
|
||||
if (AgentRulesEnabled()) {
|
||||
if (mUnsafeRulesEnabled) {
|
||||
enabledState |= nsCSSProps::eEnabledInUASheets;
|
||||
}
|
||||
if (mIsChromeOrCertifiedApp) {
|
||||
|
@ -1218,12 +1204,8 @@ protected:
|
|||
// True when the unitless length quirk applies.
|
||||
bool mUnitlessLengthQuirk : 1;
|
||||
|
||||
// Controls access to nonstandard style constructs that are not safe
|
||||
// for use on the public Web but necessary in UA sheets and/or
|
||||
// useful in user sheets. The only values stored in this field are
|
||||
// 0, 1, and 2; three bits are allocated to avoid issues should the
|
||||
// enum type be signed.
|
||||
SheetParsingMode mParsingMode : 3;
|
||||
// True if unsafe rules should be allowed
|
||||
bool mUnsafeRulesEnabled : 1;
|
||||
|
||||
// True if we are in parsing rules for Chrome or Certified App content,
|
||||
// in which case CSS properties with the
|
||||
|
@ -1352,7 +1334,7 @@ CSSParserImpl::CSSParserImpl()
|
|||
mNavQuirkMode(false),
|
||||
mHashlessColorQuirk(false),
|
||||
mUnitlessLengthQuirk(false),
|
||||
mParsingMode(eAuthorSheetFeatures),
|
||||
mUnsafeRulesEnabled(false),
|
||||
mIsChromeOrCertifiedApp(false),
|
||||
mViewportUnitsEnabled(true),
|
||||
mHTMLMediaMode(false),
|
||||
|
@ -1459,7 +1441,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
|||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber,
|
||||
SheetParsingMode aParsingMode)
|
||||
bool aAllowUnsafeRules)
|
||||
{
|
||||
NS_PRECONDITION(aSheetPrincipal, "Must have principal here!");
|
||||
NS_PRECONDITION(aBaseURI, "need base URI");
|
||||
|
@ -1504,7 +1486,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
|||
mSection = eCSSSection_Charset; // sheet is empty, any rules are fair
|
||||
}
|
||||
|
||||
mParsingMode = aParsingMode;
|
||||
mUnsafeRulesEnabled = aAllowUnsafeRules;
|
||||
mIsChromeOrCertifiedApp =
|
||||
dom::IsChromeURI(aSheetURI) ||
|
||||
aSheetPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
|
||||
|
@ -1530,7 +1512,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
|||
}
|
||||
ReleaseScanner();
|
||||
|
||||
mParsingMode = eAuthorSheetFeatures;
|
||||
mUnsafeRulesEnabled = false;
|
||||
mIsChromeOrCertifiedApp = false;
|
||||
|
||||
// XXX check for low level errors
|
||||
|
@ -1708,7 +1690,7 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
|
|||
// Check for unknown or preffed off properties
|
||||
if (eCSSProperty_UNKNOWN == aPropID ||
|
||||
!(nsCSSProps::IsEnabled(aPropID) ||
|
||||
(AgentRulesEnabled() &&
|
||||
(mUnsafeRulesEnabled &&
|
||||
nsCSSProps::PropHasFlags(aPropID,
|
||||
CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS)))) {
|
||||
NS_ConvertASCIItoUTF16 propName(nsCSSProps::GetStringValue(aPropID));
|
||||
|
@ -2999,14 +2981,8 @@ CSSParserImpl::ParseAtRule(RuleAppendFunc aAppendFunc,
|
|||
newSection = eCSSSection_General;
|
||||
|
||||
} else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-document")) {
|
||||
if (UserRulesEnabled()) {
|
||||
parseFunc = &CSSParserImpl::ParseMozDocumentRule;
|
||||
newSection = eCSSSection_General;
|
||||
} else {
|
||||
REPORT_UNEXPECTED_TOKEN(PEMozDocumentRuleNotAllowed);
|
||||
OUTPUT_ERROR();
|
||||
return SkipAtRule(aInAtRule);
|
||||
}
|
||||
parseFunc = &CSSParserImpl::ParseMozDocumentRule;
|
||||
newSection = eCSSSection_General;
|
||||
|
||||
} else if (mToken.mIdent.LowerCaseEqualsLiteral("font-face")) {
|
||||
parseFunc = &CSSParserImpl::ParseFontFaceRule;
|
||||
|
@ -5614,7 +5590,7 @@ CSSParserImpl::ParsePseudoSelector(int32_t& aDataMask,
|
|||
bool pseudoClassIsUserAction =
|
||||
nsCSSPseudoClasses::IsUserActionPseudoClass(pseudoClassType);
|
||||
|
||||
if (!AgentRulesEnabled() &&
|
||||
if (!mUnsafeRulesEnabled &&
|
||||
((pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount &&
|
||||
nsCSSPseudoElements::PseudoElementIsUASheetOnly(pseudoElementType)) ||
|
||||
(pseudoClassType != nsCSSPseudoClasses::ePseudoClass_NotPseudoClass &&
|
||||
|
@ -5650,10 +5626,10 @@ CSSParserImpl::ParsePseudoSelector(int32_t& aDataMask,
|
|||
bool isPseudoElement =
|
||||
(pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount);
|
||||
// anonymous boxes are only allowed if they're the tree boxes or we have
|
||||
// enabled agent rules
|
||||
// enabled unsafe rules
|
||||
bool isAnonBox = isTreePseudo ||
|
||||
(pseudoElementType == nsCSSPseudoElements::ePseudo_AnonBox &&
|
||||
AgentRulesEnabled());
|
||||
mUnsafeRulesEnabled);
|
||||
bool isPseudoClass =
|
||||
(pseudoClassType != nsCSSPseudoClasses::ePseudoClass_NotPseudoClass);
|
||||
|
||||
|
@ -10485,11 +10461,11 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue,
|
|||
return false;
|
||||
}
|
||||
|
||||
// We only allow 'script-level' when agent rules are enabled, because
|
||||
// We only allow 'script-level' when unsafe rules are enabled, because
|
||||
// otherwise it could interfere with rulenode optimizations if used in
|
||||
// a non-MathML-enabled document. We also only allow math-display when
|
||||
// agent rules are enabled.
|
||||
if (!AgentRulesEnabled() &&
|
||||
// unsafe rules are enabled.
|
||||
if (!mUnsafeRulesEnabled &&
|
||||
(aPropID == eCSSProperty_script_level ||
|
||||
aPropID == eCSSProperty_math_display))
|
||||
return false;
|
||||
|
@ -15805,11 +15781,11 @@ nsCSSParser::ParseSheet(const nsAString& aInput,
|
|||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber,
|
||||
SheetParsingMode aParsingMode)
|
||||
bool aAllowUnsafeRules)
|
||||
{
|
||||
return static_cast<CSSParserImpl*>(mImpl)->
|
||||
ParseSheet(aInput, aSheetURI, aBaseURI, aSheetPrincipal, aLineNumber,
|
||||
aParsingMode);
|
||||
aAllowUnsafeRules);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#define nsCSSParser_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
|
||||
#include "nsCSSProperty.h"
|
||||
#include "nsCSSScanner.h"
|
||||
|
@ -33,6 +32,7 @@ class CSSVariableValues;
|
|||
namespace css {
|
||||
class Rule;
|
||||
class Declaration;
|
||||
class Loader;
|
||||
class StyleRule;
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
@ -77,14 +77,15 @@ public:
|
|||
* @param aSheetPrincipal the principal of the stylesheet. This must match
|
||||
* the principal of the sheet passed to SetStyleSheet.
|
||||
* @param aLineNumber the line number of the first line of the sheet.
|
||||
* @param aParsingMode see SheetParsingMode in css/Loader.h
|
||||
* @param aAllowUnsafeRules see aEnableUnsafeRules in
|
||||
* mozilla::css::Loader::LoadSheetSync
|
||||
*/
|
||||
nsresult ParseSheet(const nsAString& aInput,
|
||||
nsIURI* aSheetURL,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
bool aAllowUnsafeRules);
|
||||
|
||||
// Parse HTML style attribute or its equivalent in other markup
|
||||
// languages. aBaseURL is the base url to use for relative links in
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsPrintfCString.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::css;
|
||||
|
||||
static bool sNumberControlEnabled;
|
||||
|
||||
|
@ -60,7 +59,7 @@ nsLayoutStylesheetCache::ScrollbarsSheet()
|
|||
if (!gStyleCache->mScrollbarsSheet) {
|
||||
// Scrollbars don't need access to unsafe rules
|
||||
LoadSheetURL("chrome://global/skin/scrollbars.css",
|
||||
gStyleCache->mScrollbarsSheet, eAuthorSheetFeatures);
|
||||
gStyleCache->mScrollbarsSheet, false);
|
||||
}
|
||||
|
||||
return gStyleCache->mScrollbarsSheet;
|
||||
|
@ -74,7 +73,7 @@ nsLayoutStylesheetCache::FormsSheet()
|
|||
if (!gStyleCache->mFormsSheet) {
|
||||
// forms.css needs access to unsafe rules
|
||||
LoadSheetURL("resource://gre-resources/forms.css",
|
||||
gStyleCache->mFormsSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mFormsSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mFormsSheet;
|
||||
|
@ -91,7 +90,7 @@ nsLayoutStylesheetCache::NumberControlSheet()
|
|||
|
||||
if (!gStyleCache->mNumberControlSheet) {
|
||||
LoadSheetURL("resource://gre-resources/number-control.css",
|
||||
gStyleCache->mNumberControlSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mNumberControlSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mNumberControlSheet;
|
||||
|
@ -118,7 +117,7 @@ nsLayoutStylesheetCache::UASheet()
|
|||
|
||||
if (!gStyleCache->mUASheet) {
|
||||
LoadSheetURL("resource://gre-resources/ua.css",
|
||||
gStyleCache->mUASheet, eAgentSheetFeatures);
|
||||
gStyleCache->mUASheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mUASheet;
|
||||
|
@ -131,7 +130,7 @@ nsLayoutStylesheetCache::HTMLSheet()
|
|||
|
||||
if (!gStyleCache->mHTMLSheet) {
|
||||
LoadSheetURL("resource://gre-resources/html.css",
|
||||
gStyleCache->mHTMLSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mHTMLSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mHTMLSheet;
|
||||
|
@ -179,7 +178,7 @@ nsLayoutStylesheetCache::MathMLSheet()
|
|||
|
||||
if (!gStyleCache->mMathMLSheet) {
|
||||
LoadSheetURL("resource://gre-resources/mathml.css",
|
||||
gStyleCache->mMathMLSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mMathMLSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mMathMLSheet;
|
||||
|
@ -200,7 +199,7 @@ nsLayoutStylesheetCache::NoScriptSheet()
|
|||
|
||||
if (!gStyleCache->mNoScriptSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noscript.css",
|
||||
gStyleCache->mNoScriptSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mNoScriptSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoScriptSheet;
|
||||
|
@ -213,7 +212,7 @@ nsLayoutStylesheetCache::NoFramesSheet()
|
|||
|
||||
if (!gStyleCache->mNoFramesSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noframes.css",
|
||||
gStyleCache->mNoFramesSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mNoFramesSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoFramesSheet;
|
||||
|
@ -252,7 +251,7 @@ nsLayoutStylesheetCache::ContentEditableSheet()
|
|||
|
||||
if (!gStyleCache->mContentEditableSheet) {
|
||||
LoadSheetURL("resource://gre/res/contenteditable.css",
|
||||
gStyleCache->mContentEditableSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mContentEditableSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mContentEditableSheet;
|
||||
|
@ -265,7 +264,7 @@ nsLayoutStylesheetCache::DesignModeSheet()
|
|||
|
||||
if (!gStyleCache->mDesignModeSheet) {
|
||||
LoadSheetURL("resource://gre/res/designmode.css",
|
||||
gStyleCache->mDesignModeSheet, eAgentSheetFeatures);
|
||||
gStyleCache->mDesignModeSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mDesignModeSheet;
|
||||
|
@ -344,17 +343,17 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache()
|
|||
// And make sure that we load our UA sheets. No need to do this
|
||||
// per-profile, since they're profile-invariant.
|
||||
LoadSheetURL("resource://gre-resources/counterstyles.css",
|
||||
mCounterStylesSheet, eAgentSheetFeatures);
|
||||
mCounterStylesSheet, true);
|
||||
LoadSheetURL("resource://gre-resources/full-screen-override.css",
|
||||
mFullScreenOverrideSheet, eAgentSheetFeatures);
|
||||
mFullScreenOverrideSheet, true);
|
||||
LoadSheetURL("chrome://global/content/minimal-xul.css",
|
||||
mMinimalXULSheet, eAgentSheetFeatures);
|
||||
mMinimalXULSheet, true);
|
||||
LoadSheetURL("resource://gre-resources/quirk.css",
|
||||
mQuirkSheet, eAgentSheetFeatures);
|
||||
mQuirkSheet, true);
|
||||
LoadSheetURL("resource://gre/res/svg.css",
|
||||
mSVGSheet, eAgentSheetFeatures);
|
||||
mSVGSheet, true);
|
||||
LoadSheetURL("chrome://global/content/xul.css",
|
||||
mXULSheet, eAgentSheetFeatures);
|
||||
mXULSheet, true);
|
||||
|
||||
// The remaining sheets are created on-demand do to their use being rarer
|
||||
// (which helps save memory for Firefox OS apps) or because they need to
|
||||
|
@ -421,27 +420,25 @@ nsLayoutStylesheetCache::InitFromProfile()
|
|||
contentFile->Append(NS_LITERAL_STRING("userContent.css"));
|
||||
chromeFile->Append(NS_LITERAL_STRING("userChrome.css"));
|
||||
|
||||
LoadSheetFile(contentFile, mUserContentSheet, eUserSheetFeatures);
|
||||
LoadSheetFile(chromeFile, mUserChromeSheet, eUserSheetFeatures);
|
||||
LoadSheetFile(contentFile, mUserContentSheet);
|
||||
LoadSheetFile(chromeFile, mUserChromeSheet);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsLayoutStylesheetCache::LoadSheetURL(const char* aURL,
|
||||
nsRefPtr<CSSStyleSheet>& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
bool aEnableUnsafeRules)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aURL);
|
||||
LoadSheet(uri, aSheet, aParsingMode);
|
||||
LoadSheet(uri, aSheet, aEnableUnsafeRules);
|
||||
if (!aSheet) {
|
||||
NS_ERROR(nsPrintfCString("Could not load %s", aURL).get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile,
|
||||
nsRefPtr<CSSStyleSheet>& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr<CSSStyleSheet>& aSheet)
|
||||
{
|
||||
bool exists = false;
|
||||
aFile->Exists(&exists);
|
||||
|
@ -451,7 +448,7 @@ nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile,
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewFileURI(getter_AddRefs(uri), aFile);
|
||||
|
||||
LoadSheet(uri, aSheet, aParsingMode);
|
||||
LoadSheet(uri, aSheet, false);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -468,7 +465,7 @@ ErrorLoadingBuiltinSheet(nsIURI* aURI, const char* aMsg)
|
|||
void
|
||||
nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
||||
nsRefPtr<CSSStyleSheet>& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
bool aEnableUnsafeRules)
|
||||
{
|
||||
if (!aURI) {
|
||||
ErrorLoadingBuiltinSheet(aURI, "null URI");
|
||||
|
@ -485,7 +482,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
|||
}
|
||||
|
||||
|
||||
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true,
|
||||
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aEnableUnsafeRules, true,
|
||||
getter_AddRefs(aSheet));
|
||||
if (NS_FAILED(rv)) {
|
||||
ErrorLoadingBuiltinSheet(aURI,
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace css {
|
||||
class Loader;
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
||||
class nsLayoutStylesheetCache final
|
||||
|
@ -68,12 +70,11 @@ private:
|
|||
void InitMemoryReporter();
|
||||
static void LoadSheetURL(const char* aURL,
|
||||
nsRefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
bool aEnableUnsafeRules);
|
||||
static void LoadSheetFile(nsIFile* aFile,
|
||||
nsRefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
nsRefPtr<mozilla::CSSStyleSheet>& aSheet);
|
||||
static void LoadSheet(nsIURI* aURI, nsRefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
bool aEnableUnsafeRules);
|
||||
static void InvalidateSheet(nsRefPtr<mozilla::CSSStyleSheet>& aSheet);
|
||||
static void DependentPrefChanged(const char* aPref, void* aData);
|
||||
void BuildPreferenceSheet(nsRefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
|
|
|
@ -8,9 +8,6 @@ support-files =
|
|||
hover_helper.html
|
||||
match.png
|
||||
mismatch.png
|
||||
moz_document_condition_text.css
|
||||
moz_document_nesting.css
|
||||
moz_document_serialization.css
|
||||
|
||||
[test_addSheet.html]
|
||||
[test_additional_sheets.html]
|
||||
|
@ -21,9 +18,4 @@ support-files =
|
|||
[test_bug535806.xul]
|
||||
[test_hover.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_moz_document_condition_text.html]
|
||||
[test_moz_document_crashes.html]
|
||||
[test_moz_document_matching.html]
|
||||
[test_moz_document_nesting.html]
|
||||
[test_moz_document_serialization.html]
|
||||
[test_moz_document_usability.html]
|
||||
[test_moz_document_rules.html]
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
/* Bug 814907 (@-moz-document cases) */
|
||||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
|
@ -1,89 +0,0 @@
|
|||
/* formerly test_bug511909.html */
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
#pink {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
#green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#blue {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#d {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
#m {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
#dm {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#md {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* syntax error - recover at end of @media block */
|
||||
@media print { @-moz-document regexp("not_this_url") , }
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
/* syntax error - recover at end of @-moz-document block */
|
||||
@-moz-document regexp("not_this_url") { @media , }
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@media screen {
|
||||
#me {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* formerly reftests/w3c-css/submitted/conditional3/css-supports-027.xht */
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
@supports (color: green) {
|
||||
#mf { color: green }
|
||||
}
|
||||
}
|
||||
|
||||
/* formerly reftests/w3c-css/submitted/conditional3/css-supports-028.xht */
|
||||
@supports (color: pink) {
|
||||
@-moz-document regexp(".*test_moz_document_nesting.*") {
|
||||
#mg { color: pink }
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
|
@ -1,61 +0,0 @@
|
|||
<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Test for Bug 814907 (@-moz-document cases)</title>
|
||||
<!-- Split from test_condition_text.html.
|
||||
This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script type="application/javascript" src="/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/content/tests/SimpleTest/test.css"/>
|
||||
</head><body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=814907">Mozilla Bug 814907</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_condition_text.css", null, document.baseURIObject);
|
||||
|
||||
var sheet =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService)
|
||||
.preloadSheet(sheetURI, Components.interfaces.nsIStyleSheetService.USER_SHEET);
|
||||
|
||||
windowUtils.addSheet(sheet, windowUtils.USER_SHEET);
|
||||
|
||||
addLoadEvent(function () {
|
||||
var conditions = [
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"domain(\"example.com\")",
|
||||
"domain(\"example.com\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
];
|
||||
|
||||
is(sheet.cssRules.length, conditions.length);
|
||||
|
||||
for (var i = 0; i < sheet.cssRules.length; i++) {
|
||||
var rule = sheet.cssRules[i];
|
||||
is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
|
||||
if (rule.type == CSSRule.MEDIA_RULE) {
|
||||
is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,53 +0,0 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@-moz-document crash tests</title>
|
||||
<!-- This test was formerly known as
|
||||
crashtests/long-url-list-stack-overflow.html and
|
||||
crashtests/495269-2.html.
|
||||
|
||||
This is a chrome mochitest because @-moz-document can only be
|
||||
used from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
</head><body>
|
||||
<script>
|
||||
// Duplicates the string 2^n times
|
||||
function exp(s, n)
|
||||
{
|
||||
for (var i = 0; i < n; ++i)
|
||||
s += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var ios =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var sss =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService);
|
||||
|
||||
var style = "@-moz-document url(http://www.w3.org/)" + exp(", url-prefix(file:///)", 20) + " { }";
|
||||
var url1 = ios.newURI("data:text/css," + style, null, null)
|
||||
|
||||
// should not crash at this point
|
||||
windowUtils.loadSheet(url1, windowUtils.USER_SHEET);
|
||||
ok(true, "long-url-list-stack-overflow: no crash");
|
||||
|
||||
var url2 = ios.newURI("data:text/css,@-moz-document domain(example.com) {}';", null, null);
|
||||
|
||||
var sheet1 = sss.preloadSheet(url2, sss.USER_SHEET);
|
||||
var sheet2 = sss.preloadSheet(url2, sss.USER_SHEET);
|
||||
windowUtils.addSheet(sheet1, windowUtils.USER_SHEET);
|
||||
windowUtils.addSheet(sheet2, windowUtils.USER_SHEET);
|
||||
|
||||
// Force a unique inner for the second linked sheet; should not crash
|
||||
sheet2.cssRules[0];
|
||||
ok(true, "495269-2: no crash");
|
||||
</script>
|
||||
</body></html>
|
|
@ -1,120 +0,0 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@media and @-moz-document testcases</title>
|
||||
<!-- This test was formerly known as test_bug511909.html.
|
||||
This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
</head><body>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_nesting.css", null, document.baseURIObject);
|
||||
|
||||
windowUtils.loadSheet(sheetURI, windowUtils.USER_SHEET);
|
||||
|
||||
addLoadEvent(function() {
|
||||
var pink = getComputedStyle(document.getElementById("pink"), "");
|
||||
var green = getComputedStyle(document.getElementById("green"), "");
|
||||
var blue = getComputedStyle(document.getElementById("blue"), "");
|
||||
|
||||
var cs1 = getComputedStyle(document.getElementById("d"), "");
|
||||
var cs2 = getComputedStyle(document.getElementById("m"), "");
|
||||
var cs3 = getComputedStyle(document.getElementById("dm"), "");
|
||||
var cs4 = getComputedStyle(document.getElementById("md"), "");
|
||||
var cs5 = getComputedStyle(document.getElementById("mx"), "");
|
||||
var cs6 = getComputedStyle(document.getElementById("mxx"), "");
|
||||
var cs7 = getComputedStyle(document.getElementById("me"), "");
|
||||
var cs8 = getComputedStyle(document.getElementById("mf"), "");
|
||||
var cs9 = getComputedStyle(document.getElementById("mg"), "");
|
||||
|
||||
is(cs1.color, pink.color, "@-moz-document applies");
|
||||
is(cs2.color, green.color, "@media applies");
|
||||
is(cs3.color, blue.color, "@media nested in @-moz-document applies");
|
||||
is(cs4.color, green.color, "@-moz-document nested in @media applies");
|
||||
is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled");
|
||||
is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled");
|
||||
is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
|
||||
is(cs8.color, green.color, "@supports nested in @-moz-document applies");
|
||||
is(cs9.color, pink.color, "@-moz-document nested in @supports applies");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
|
||||
<pre>default style
|
||||
</pre>
|
||||
<a id="pink">This line should be pink</a><br>
|
||||
<a id="green">This line should be green</a><br>
|
||||
<a id="blue">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {...}
|
||||
</pre>
|
||||
<a id="d">This line should be pink</a><br>
|
||||
|
||||
<pre>@media screen {...}
|
||||
</pre>
|
||||
<a id="m">This line should be green</a><br>
|
||||
|
||||
<pre>@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="dm">This line should be blue</a><br>
|
||||
|
||||
<pre>@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mx">This line should be pink</a><br></div>
|
||||
|
||||
<pre>@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mxx">This line should be blue</a><br>
|
||||
|
||||
<pre>@media screen {
|
||||
@-moz-document {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="md">This line should be green</a><br>
|
||||
|
||||
<pre>@media screen {
|
||||
@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="me">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {
|
||||
@supports { ... }
|
||||
}
|
||||
</pre>
|
||||
<a id="mf">This line should be green</a><br>
|
||||
|
||||
<pre>@supports {
|
||||
@-moz-document { ... }
|
||||
}
|
||||
</pre>
|
||||
<a id="mg">This line should be pink</a><br>
|
||||
|
||||
</body></html>
|
|
@ -1,50 +0,0 @@
|
|||
<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Test for reserialization of @-moz-document rules</title>
|
||||
<!-- This is a chrome test because @-moz-document can only be used
|
||||
from user style sheets. See bug 1035091. -->
|
||||
|
||||
<script type="application/javascript" src="/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/content/tests/SimpleTest/test.css"/>
|
||||
|
||||
</head><body>
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var windowUtils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var sheetURI =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI("moz_document_serialization.css", null, document.baseURIObject);
|
||||
|
||||
var sheet =
|
||||
Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService)
|
||||
.preloadSheet(sheetURI, Components.interfaces.nsIStyleSheetService.USER_SHEET);
|
||||
|
||||
windowUtils.addSheet(sheet, windowUtils.USER_SHEET);
|
||||
|
||||
var rules = [
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url("http://www.example.com/") {\n}',
|
||||
'@-moz-document url-prefix("http://www.example.com/") {\n}',
|
||||
'@-moz-document url-prefix("http://www.example.com/") {\n}',
|
||||
'@-moz-document domain("example.com") {\n}',
|
||||
'@-moz-document domain("example.com") {\n}',
|
||||
'@-moz-document regexp("http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/") {\n}',
|
||||
'@-moz-document regexp("http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/") {\n}',
|
||||
];
|
||||
|
||||
addLoadEvent(function () {
|
||||
is(sheet.cssRules.length, rules.length, "number of rules");
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
is(sheet.cssRules[i].cssText, rules[i], "serialization for rule " + i);
|
||||
}
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,56 +0,0 @@
|
|||
<!doctype html><html><head><meta charset="UTF-8">
|
||||
<title>@-moz-document usability test (Bug 1035091)</title>
|
||||
<!-- Per https://bugzilla.mozilla.org/show_bug.cgi?id=1035091
|
||||
@-moz-document rules can only be used in user and UA style sheets
|
||||
until further notice. -->
|
||||
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
|
||||
<style>
|
||||
#green { color: green }
|
||||
#author { color: green }
|
||||
#user { color: red }
|
||||
#agent { color: red }
|
||||
</style>
|
||||
</head><body>
|
||||
|
||||
<p id="green">All text should be green.</p>
|
||||
<p id="author">All text should be green.</p>
|
||||
<p id="user">All text should be green.</p>
|
||||
<p id="agent">All text should be green.</p>
|
||||
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var wu =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var ios =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
function makeSheet(whom, color) {
|
||||
return ios.newURI(
|
||||
"data:text/css,@-moz-document regexp('.*test_moz_document.*') {" +
|
||||
"%23" + whom + " { color: " + color + "!important } }",
|
||||
null, null);
|
||||
}
|
||||
wu.loadSheet(makeSheet("author", "red"), wu.AUTHOR_SHEET);
|
||||
wu.loadSheet(makeSheet("user", "green"), wu.USER_SHEET);
|
||||
wu.loadSheet(makeSheet("agent", "green"), wu.AGENT_SHEET);
|
||||
|
||||
addLoadEvent(function () {
|
||||
var green = getComputedStyle(document.getElementById("green"), "").color;
|
||||
var author = getComputedStyle(document.getElementById("author"), "").color;
|
||||
var user = getComputedStyle(document.getElementById("user"), "").color;
|
||||
var agent = getComputedStyle(document.getElementById("agent"), "").color;
|
||||
|
||||
is(author, green, "@-moz-document should not be honored in author sheets");
|
||||
is(user, green, "@-moz-document should be honored in user sheets");
|
||||
is(agent, green, "@-moz-document should be honored in agent sheets");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body></html>
|
|
@ -93,6 +93,7 @@ support-files = bug453896_iframe.html
|
|||
[test_bug470769.html]
|
||||
[test_bug499655.html]
|
||||
[test_bug499655.xhtml]
|
||||
[test_bug511909.html]
|
||||
[test_bug517224.html]
|
||||
support-files = bug517224.sjs
|
||||
[test_bug524175.html]
|
||||
|
@ -219,6 +220,7 @@ support-files = redundant_font_download.sjs
|
|||
[test_root_node_display.html]
|
||||
[test_rule_insertion.html]
|
||||
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(monospace and serif text have sufficiently different widths) b2g-desktop(monospace and serif text have sufficiently different widths)
|
||||
[test_rule_serialization.html]
|
||||
[test_rules_out_of_sheets.html]
|
||||
[test_selectors.html]
|
||||
skip-if = (toolkit == 'gonk' && debug) || toolkit == 'android' #bug 775227 #debug-only failure; timed out
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
<html><!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=511909
|
||||
--><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>@media and @-moz-document testcases</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
|
||||
<style type="text/css">
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
#pink {
|
||||
color: pink;
|
||||
}
|
||||
|
||||
#green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#blue {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
#d {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
#m {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
#dm {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- should parse -->
|
||||
<style type="text/css">
|
||||
|
||||
@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!-- should parse -->
|
||||
<style type="text/css">
|
||||
|
||||
@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
#md {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
@-moz-document regexp(".*test_bug511909.*"){
|
||||
@media screen {
|
||||
#me {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511909">Mozilla Bug 511909</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
var pink = getComputedStyle(document.getElementById("pink"), "");
|
||||
var green = getComputedStyle(document.getElementById("green"), "");
|
||||
var blue = getComputedStyle(document.getElementById("blue"), "");
|
||||
|
||||
var cs1 = getComputedStyle(document.getElementById("d"), "");
|
||||
var cs2 = getComputedStyle(document.getElementById("m"), "");
|
||||
var cs3 = getComputedStyle(document.getElementById("dm"), "");
|
||||
var cs4 = getComputedStyle(document.getElementById("md"), "");
|
||||
var cs5 = getComputedStyle(document.getElementById("mx"), "");
|
||||
var cs6 = getComputedStyle(document.getElementById("mxx"), "");
|
||||
var cs7 = getComputedStyle(document.getElementById("me"), "");
|
||||
|
||||
is(cs1.color, pink.color, "@-moz-document applies");
|
||||
is(cs2.color, green.color, "@media applies");
|
||||
is(cs3.color, blue.color, "@media nested in @-moz-document applies");
|
||||
is(cs4.color, green.color, "@-moz-document nested in @media applies");
|
||||
is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled");
|
||||
is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled");
|
||||
is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
<div>
|
||||
<pre>default style
|
||||
</pre>
|
||||
<a id="pink">This line should be pink</a><br>
|
||||
|
||||
<a id="green">This line should be green</a><br>
|
||||
|
||||
<a id="blue">This line should be blue</a><br>
|
||||
|
||||
<pre>@-moz-document {...}
|
||||
</pre>
|
||||
<a id="d">This line should be pink</a><br>
|
||||
<pre>@media screen {...}
|
||||
</pre>
|
||||
<a id="m">This line should be green</a><br>
|
||||
<pre>@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="dm">This line should be blue</a><br>
|
||||
<pre>@media print {
|
||||
@-moz-document regexp("not_this_url"),}
|
||||
#mx {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mx">This line should be pink</a><br></div>
|
||||
<pre>@-moz-document regexp("not_this_url"){
|
||||
@media print ,}
|
||||
#mxx {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="mxx">This line should be blue</a><br>
|
||||
<pre>@media screen {
|
||||
@-moz-documen {...}
|
||||
}
|
||||
</pre>
|
||||
<a id="md">This line should be green</a><br>
|
||||
<pre>@media screen {
|
||||
@-moz-document {
|
||||
@media screen {...}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<a id="me">This line should be blue</a><br>
|
||||
|
||||
|
||||
</body></html>
|
|
@ -8,6 +8,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907
|
|||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style id="style">
|
||||
@-moz-document url(http://www.example.com/) {}
|
||||
@-moz-document url('http://www.example.com/') {}
|
||||
@-moz-document url("http://www.example.com/") {}
|
||||
@-moz-document url-prefix('http://www.example.com/') {}
|
||||
@-moz-document url-prefix("http://www.example.com/") {}
|
||||
@-moz-document domain('example.com') {}
|
||||
@-moz-document domain("example.com") {}
|
||||
@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
|
||||
@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
|
||||
|
||||
@media all {}
|
||||
@media only color {}
|
||||
@media (color ) {}
|
||||
|
@ -32,33 +42,51 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907
|
|||
|
||||
/** Test for Bug 814907 **/
|
||||
|
||||
var style = document.getElementById("style");
|
||||
style.textContent += " ";
|
||||
function runTest()
|
||||
{
|
||||
// re-parse the style sheet with the pref turned on
|
||||
var style = document.getElementById("style");
|
||||
style.textContent += " ";
|
||||
|
||||
var sheet = style.sheet;
|
||||
var sheet = style.sheet;
|
||||
|
||||
var conditions = [
|
||||
"all",
|
||||
"only color",
|
||||
"(color)",
|
||||
"color and (monochrome)",
|
||||
"(max-width: 200px), (color)",
|
||||
"(color: green)",
|
||||
"(color: green)",
|
||||
"((color: green))",
|
||||
"(color: green) and (color: blue)",
|
||||
"( Font: 20px serif ! Important)"
|
||||
];
|
||||
var conditions = [
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"url-prefix(\"http://www.example.com/\")",
|
||||
"domain(\"example.com\")",
|
||||
"domain(\"example.com\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
|
||||
"all",
|
||||
"only color",
|
||||
"(color)",
|
||||
"color and (monochrome)",
|
||||
"(max-width: 200px), (color)",
|
||||
"(color: green)",
|
||||
"(color: green)",
|
||||
"((color: green))",
|
||||
"(color: green) and (color: blue)",
|
||||
"( Font: 20px serif ! Important)"
|
||||
];
|
||||
|
||||
is(sheet.cssRules.length, conditions.length);
|
||||
is(sheet.cssRules.length, conditions.length);
|
||||
|
||||
for (var i = 0; i < sheet.cssRules.length; i++) {
|
||||
var rule = sheet.cssRules[i];
|
||||
is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
|
||||
if (rule.type == CSSRule.MEDIA_RULE) {
|
||||
is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
|
||||
for (var i = 0; i < sheet.cssRules.length; i++) {
|
||||
var rule = sheet.cssRules[i];
|
||||
is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
|
||||
if (rule.type == CSSRule.MEDIA_RULE) {
|
||||
is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -183,6 +183,16 @@ const tests = [
|
|||
ref: "@namespace 'http://foo.example.com/';",
|
||||
tst: "@namespace 'http://foo.example.com/"
|
||||
},
|
||||
{
|
||||
name: "@-moz-document 1",
|
||||
ref: "@-moz-document domain('example.com') {}",
|
||||
tst: "@-moz-document domain('example.com') {"
|
||||
},
|
||||
{
|
||||
name: "@-moz-document 2",
|
||||
ref: "@-moz-document domain('example.com') { p {} }",
|
||||
tst: "@-moz-document domain('example.com') { p {"
|
||||
}
|
||||
];
|
||||
|
||||
const basestyle = ("table {\n"+
|
||||
|
|
|
@ -69,6 +69,7 @@ var cjkDecimalWidth = controlCJKDecimal.getBoundingClientRect().width;
|
|||
// [at-rule type, passing condition, failing condition]
|
||||
var outerRuleInfo = [
|
||||
["@media", "all", "not all"],
|
||||
["@-moz-document", "url-prefix('')", "url-prefix('zzz')"],
|
||||
["@supports", "(color: green)", "(unknown: unknown)"]
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug </title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style type="text/css" id="style"></style>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var rules = [
|
||||
{ rule: "@-moz-document url(http://www.example.com/) {}" },
|
||||
{ rule: "@-moz-document url('http://www.example.com/') {}" },
|
||||
{ rule: '@-moz-document url("http://www.example.com/") {}' },
|
||||
{ rule: "@-moz-document url-prefix('http://www.example.com/') {}" },
|
||||
{ rule: '@-moz-document url-prefix("http://www.example.com/") {}' },
|
||||
{ rule: "@-moz-document domain('example.com') {}" },
|
||||
{ rule: '@-moz-document domain("example.com") {}' },
|
||||
{ rule: "@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}" },
|
||||
{ rule: '@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}' },
|
||||
];
|
||||
|
||||
var style = document.getElementById("style");
|
||||
var style_text = document.createTextNode("");
|
||||
style.appendChild(style_text);
|
||||
|
||||
for (var i in rules) {
|
||||
var obj = rules[i];
|
||||
var rule = obj.rule;
|
||||
|
||||
style_text.data = rule;
|
||||
is(style.sheet.cssRules.length, 1, "should have one rule");
|
||||
var ser1 = style.sheet.cssRules[0].cssText;
|
||||
if ("is_canonical" in obj) {
|
||||
is(ser1, rule, "rule '" + rule + "' should serialize to itself");
|
||||
}
|
||||
|
||||
style_text.data = ser1;
|
||||
is(style.sheet.cssRules.length, 1, "should have one rule");
|
||||
var ser2 = style.sheet.cssRules[0].cssText;
|
||||
is(ser2, ser1,
|
||||
"parse+serialize for rule '" + rule + "' should be idempotent");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче