Backed out 4 changesets (bug 1107378) as a last grasped straw to figure out the m-dt bustage on a CLOSED TREE

Backed out changeset 44144b892414 (bug 1107378)
Backed out changeset 5a8d5e8ff524 (bug 1107378)
Backed out changeset 960037d0fc98 (bug 1107378)
Backed out changeset 23fb39cb0f97 (bug 1107378)
This commit is contained in:
Wes Kocher 2015-02-26 23:35:25 -08:00
parent 76f7dd6e6f
commit 59292e7b10
11 changed files with 4 additions and 722 deletions

View File

@ -537,8 +537,6 @@
@BINPATH@/components/formautofill.manifest
@BINPATH@/components/FormAutofillContentService.js
@BINPATH@/components/FormAutofillStartup.js
@BINPATH@/components/CSSUnprefixingService.js
@BINPATH@/components/CSSUnprefixingService.manifest
@BINPATH@/components/contentAreaDropListener.manifest
@BINPATH@/components/contentAreaDropListener.js
@BINPATH@/components/messageWakeupService.js

View File

@ -476,8 +476,6 @@
@RESPATH@/components/formautofill.manifest
@RESPATH@/components/FormAutofillContentService.js
@RESPATH@/components/FormAutofillStartup.js
@RESPATH@/components/CSSUnprefixingService.js
@RESPATH@/components/CSSUnprefixingService.manifest
@RESPATH@/components/contentAreaDropListener.manifest
@RESPATH@/components/contentAreaDropListener.js
@RESPATH@/browser/components/BrowserProfileMigrators.manifest

View File

@ -1,157 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Implementation of a service that converts certain vendor-prefixed CSS
properties to their unprefixed equivalents, for sites on a whitelist. */
// XXXdholbert whitelist is coming in bug 1132743
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function CSSUnprefixingService() {
}
CSSUnprefixingService.prototype = {
// Boilerplate:
classID: Components.ID("{f0729490-e15c-4a2f-a3fb-99e1cc946b42}"),
_xpcom_factory: XPCOMUtils.generateSingletonFactory(CSSUnprefixingService),
QueryInterface: XPCOMUtils.generateQI([Ci.nsICSSUnprefixingService]),
// See documentation in nsICSSUnprefixingService.idl
generateUnprefixedDeclaration: function(aPropName, aRightHalfOfDecl,
aUnprefixedDecl /*out*/) {
// Convert our input strings to lower-case, for easier string-matching.
// (NOTE: If we ever need to add support for unprefixing properties that
// have case-sensitive parts, then we should do these toLowerCase()
// conversions in a more targeted way, to avoid breaking those properties.)
aPropName = aPropName.toLowerCase();
aRightHalfOfDecl = aRightHalfOfDecl.toLowerCase();
// We have several groups of supported properties:
// FIRST GROUP: Properties that can just be handled as aliases:
// ============================================================
const propertiesThatAreJustAliases = {
"-webkit-background-size": "background-size",
"-webkit-box-flex": "flex-grow",
"-webkit-box-ordinal-group": "order",
"-webkit-box-sizing": "box-sizing",
"-webkit-transform": "transform",
};
let unprefixedPropName = propertiesThatAreJustAliases[aPropName];
if (unprefixedPropName !== undefined) {
aUnprefixedDecl.value = unprefixedPropName + ":" + aRightHalfOfDecl;
return true;
}
// SECOND GROUP: Properties that take a single keyword, where the
// unprefixed version takes a different (but analogous) set of keywords:
// =====================================================================
const propertiesThatNeedKeywordMapping = {
"-webkit-box-align" : {
unprefixedPropName : "align-items",
valueMap : {
"start" : "flex-start",
"center" : "center",
"end" : "flex-end",
"baseline" : "baseline",
"stretch" : "stretch"
}
},
"-webkit-box-orient" : {
unprefixedPropName : "flex-direction",
valueMap : {
"horizontal" : "row",
"inline-axis" : "row",
"vertical" : "column",
"block-axis" : "column"
}
},
"-webkit-box-pack" : {
unprefixedPropName : "justify-content",
valueMap : {
"start" : "flex-start",
"center" : "center",
"end" : "flex-end",
"justify" : "space-between"
}
},
};
let propInfo = propertiesThatNeedKeywordMapping[aPropName];
if (typeof(propInfo) != "undefined") {
// Regexp for parsing the right half of a declaration, for keyword-valued
// properties. Divides the right half of the declaration into:
// 1) any leading whitespace
// 2) the property value (one or more alphabetical character or hyphen)
// 3) anything after that (e.g. "!important", ";")
// Then we can look up the appropriate unprefixed-property value for the
// value (part 2), and splice that together with the other parts and with
// the unprefixed property-name to make the final declaration.
const keywordValuedPropertyRegexp = /^(\s*)([a-z\-]+)(.*)/;
let parts = keywordValuedPropertyRegexp.exec(aRightHalfOfDecl);
if (!parts) {
// Failed to parse a keyword out of aRightHalfOfDecl. (It probably has
// no alphabetical characters.)
return false;
}
let mappedKeyword = propInfo.valueMap[parts[2]];
if (mappedKeyword === undefined) {
// We found a keyword in aRightHalfOfDecl, but we don't have a mapping
// to an equivalent keyword for the unprefixed version of the property.
return false;
}
aUnprefixedDecl.value = propInfo.unprefixedPropName + ":" +
parts[1] + // any leading whitespace
mappedKeyword +
parts[3]; // any trailing text (e.g. !important, semicolon, etc)
return true;
}
// THIRD GROUP: Properties that may need arbitrary string-replacement:
// ===================================================================
const propertiesThatNeedStringReplacement = {
// "-webkit-transition" takes a multi-part value. If "-webkit-transform"
// appears as part of that value, replace it w/ "transform".
// And regardless, we unprefix the "-webkit-transition" property-name.
// (We could handle other prefixed properties in addition to 'transform'
// here, but in practice "-webkit-transform" is the main one that's
// likely to be transitioned & that we're concerned about supporting.)
"-webkit-transition": {
unprefixedPropName : "transition",
stringMap : {
"-webkit-transform" : "transform",
}
},
};
propInfo = propertiesThatNeedStringReplacement[aPropName];
if (typeof(propInfo) != "undefined") {
let newRightHalf = aRightHalfOfDecl;
for (let strToReplace in propInfo.stringMap) {
let replacement = propInfo.stringMap[strToReplace];
newRightHalf = newRightHalf.replace(strToReplace, replacement, "g");
}
aUnprefixedDecl.value = propInfo.unprefixedPropName + ":" + newRightHalf;
return true;
}
// No known mapping for property aPropName.
return false;
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([CSSUnprefixingService]);

View File

@ -1,2 +0,0 @@
component {f0729490-e15c-4a2f-a3fb-99e1cc946b42} CSSUnprefixingService.js
contract @mozilla.org/css-unprefixing-service;1 {f0729490-e15c-4a2f-a3fb-99e1cc946b42}

View File

@ -7,12 +7,6 @@
DIRS += ['xbl-marquee']
TEST_DIRS += ['test']
XPIDL_SOURCES += [
'nsICSSUnprefixingService.idl',
]
XPIDL_MODULE = 'layout_base'
EXPORTS += [
'AnimationCommon.h',
'CounterStyleManager.h',
@ -153,11 +147,6 @@ SOURCES += [
'nsCSSRuleProcessor.cpp',
]
EXTRA_COMPONENTS += [
'CSSUnprefixingService.js',
'CSSUnprefixingService.manifest',
]
FAIL_ON_WARNINGS = True
MSVC_ENABLE_PGO = True

View File

@ -38,7 +38,6 @@
#include "nsIMediaList.h"
#include "nsStyleUtil.h"
#include "nsIPrincipal.h"
#include "nsICSSUnprefixingService.h"
#include "prprf.h"
#include "nsContentUtils.h"
#include "nsAutoPtr.h"
@ -57,7 +56,6 @@ typedef nsCSSProps::KTableValue KTableValue;
// pref-backed bool values (hooked up in nsCSSParser::Startup)
static bool sOpentypeSVGEnabled;
static bool sUnprefixingServiceEnabled;
const uint32_t
nsCSSProps::kParserVariantTable[eCSSProperty_COUNT_no_shorthands] = {
@ -418,103 +416,6 @@ protected:
nsIURI* aSheetURI, nsIURI* aBaseURI,
nsIPrincipal* aSheetPrincipal);
void ReleaseScanner(void);
/**
* This is a RAII class which behaves like an "AutoRestore<>" for our parser
* input state. When instantiated, this class saves the current parser input
* state (in a CSSParserInputState object), and it restores the parser to
* that state when destructed, unless "DoNotRestore()" has been called.
*/
class MOZ_STACK_CLASS nsAutoCSSParserInputStateRestorer {
public:
explicit nsAutoCSSParserInputStateRestorer(CSSParserImpl* aParser
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mParser(aParser),
mShouldRestore(true)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
mParser->SaveInputState(mSavedState);
}
void DoNotRestore()
{
mShouldRestore = false;
}
~nsAutoCSSParserInputStateRestorer()
{
if (mShouldRestore) {
mParser->RestoreSavedInputState(mSavedState);
}
}
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
CSSParserImpl* mParser;
CSSParserInputState mSavedState;
bool mShouldRestore;
};
/**
* This is a RAII class which creates a temporary nsCSSScanner for the given
* string, and reconfigures aParser to use *that* scanner instead of its
* existing scanner, until we go out of scope. (This allows us to rewrite
* a portion of a stylesheet using a temporary string, and switch to parsing
* that rewritten section, and then resume parsing the original stylesheet.)
*
* aParser must have a non-null nsCSSScanner (which we'll be temporarily
* replacing) and ErrorReporter (which this class will co-opt for the
* temporary parser). While we're in scope, we also suppress error reporting,
* so it doesn't really matter which reporter we use. We suppress reporting
* because this class is only used with CSS that is synthesized & didn't
* come directly from an author, and it would be confusing if we reported
* syntax errors for CSS that an author didn't provide.
*
* XXXdholbert we could also change this & report errors, if needed. Might
* want to customize the error reporting somehow though.
*/
class MOZ_STACK_CLASS nsAutoScannerChanger {
public:
nsAutoScannerChanger(CSSParserImpl* aParser,
const nsAString& aStringToScan
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mParser(aParser),
mOriginalScanner(aParser->mScanner),
mStringScanner(aStringToScan, 0),
mParserStateRestorer(aParser),
mErrorSuppresser(aParser)
{
MOZ_ASSERT(mOriginalScanner,
"Shouldn't use nsAutoScannerChanger unless we already "
"have a scanner");
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
// Set & setup the new scanner:
mParser->mScanner = &mStringScanner;
mStringScanner.SetErrorReporter(mParser->mReporter);
// We might've had push-back on our original scanner (and if we did,
// that fact is saved via mParserStateRestorer). But we don't have
// push-back in mStringScanner, so clear that flag.
mParser->mHavePushBack = false;
}
~nsAutoScannerChanger()
{
// Restore original scanner. All other cleanup is done by RAII members.
mParser->mScanner = mOriginalScanner;
}
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
CSSParserImpl* mParser;
nsCSSScanner *mOriginalScanner;
nsCSSScanner mStringScanner;
nsAutoCSSParserInputStateRestorer mParserStateRestorer;
nsAutoSuppressErrors mErrorSuppresser;
};
bool IsSVGMode() const {
return mScanner->IsSVGMode();
}
@ -704,10 +605,8 @@ protected:
bool ParseSelector(nsCSSSelectorList* aList, char16_t aPrevCombinator);
enum {
eParseDeclaration_InBraces = 1 << 0,
eParseDeclaration_AllowImportant = 1 << 1,
// The declaration we're parsing was generated by the CSSUnprefixingService:
eParseDeclaration_FromUnprefixingSvc = 1 << 2
eParseDeclaration_InBraces = 1 << 0,
eParseDeclaration_AllowImportant = 1 << 1
};
enum nsCSSContextType {
eCSSContext_General,
@ -722,21 +621,6 @@ protected:
bool* aChanged,
nsCSSContextType aContext = eCSSContext_General);
// A "prefix-aware" wrapper for nsCSSKeywords::LookupKeyword().
// Use this instead of LookupKeyword() if you might be parsing an unprefixed
// property (like "display") for which we emulate a vendor-prefixed value
// (like "-webkit-box").
nsCSSKeyword LookupKeywordPrefixAware(nsAString& aKeywordStr,
const KTableValue aKeywordTable[]);
bool ShouldUseUnprefixingService();
bool ParsePropertyWithUnprefixingService(const nsAString& aPropertyName,
css::Declaration* aDeclaration,
uint32_t aFlags,
bool aMustCallValueAppended,
bool* aChanged,
nsCSSContextType aContext);
bool ParseProperty(nsCSSProperty aPropID);
bool ParsePropertyByFunction(nsCSSProperty aPropID);
bool ParseSingleValueProperty(nsCSSValue& aValue,
@ -1202,12 +1086,6 @@ protected:
// @supports rule.
bool mSuppressErrors : 1;
// True if we've parsed "display: -webkit-box" as "display: flex" in an
// earlier declaration within the current block of declarations, as part of
// emulating support for certain -webkit-prefixed properties on certain
// sites.
bool mDidUnprefixWebkitBoxInEarlierDecl; // not :1 so we can use AutoRestore
// Stack of rule groups; used for @media and such.
InfallibleTArray<nsRefPtr<css::GroupRule> > mGroupStack;
@ -1284,7 +1162,6 @@ CSSParserImpl::CSSParserImpl()
mInSupportsCondition(false),
mInFailingSupportsRule(false),
mSuppressErrors(false),
mDidUnprefixWebkitBoxInEarlierDecl(false),
mNextFree(nullptr)
{
}
@ -1513,10 +1390,6 @@ CSSParserImpl::ParseDeclarations(const nsAString& aBuffer,
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aSheetURI);
InitScanner(scanner, reporter, aSheetURI, aBaseURI, aSheetPrincipal);
MOZ_ASSERT(!mDidUnprefixWebkitBoxInEarlierDecl,
"Someone forgot to clear the 'did unprefix webkit-box' flag");
AutoRestore<bool> autoRestore(mDidUnprefixWebkitBoxInEarlierDecl);
mSection = eCSSSection_General;
mData.AssertInitialState();
@ -6161,10 +6034,6 @@ CSSParserImpl::ParseDeclarationBlock(uint32_t aFlags, nsCSSContextType aContext)
{
bool checkForBraces = (aFlags & eParseDeclaration_InBraces) != 0;
MOZ_ASSERT(!mDidUnprefixWebkitBoxInEarlierDecl,
"Someone forgot to clear the 'did unprefix webkit-box' flag");
AutoRestore<bool> restorer(mDidUnprefixWebkitBoxInEarlierDecl);
if (checkForBraces) {
if (!ExpectSymbol('{', true)) {
REPORT_UNEXPECTED_TOKEN(PEBadDeclBlockStart);
@ -6572,108 +6441,6 @@ CSSParserImpl::ParseTreePseudoElement(nsAtomList **aPseudoElementArgs)
}
#endif
nsCSSKeyword
CSSParserImpl::LookupKeywordPrefixAware(nsAString& aKeywordStr,
const KTableValue aKeywordTable[])
{
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aKeywordStr);
if (aKeywordTable == nsCSSProps::kDisplayKTable) {
if (keyword == eCSSKeyword_UNKNOWN &&
ShouldUseUnprefixingService() &&
aKeywordStr.EqualsLiteral("-webkit-box")) {
// Treat "display: -webkit-box" as "display: flex". In simple scenarios,
// they largely behave the same, as long as we use the CSS Unprefixing
// Service to also translate the associated properties.
mDidUnprefixWebkitBoxInEarlierDecl = true;
return eCSSKeyword_flex;
}
// If we've seen "display: -webkit-box" in an earlier declaration and we
// tried to unprefix it to emulate support for it, then we have to watch
// out for later "display: -moz-box" declarations; they're likely just a
// halfhearted attempt at compatibility, and they actually end up stomping
// on our emulation of the earlier -webkit-box display-value, via the CSS
// cascade. To prevent this problem, we also treat "display: -moz-box" as
// "display: flex" (but only if we unprefixed an earlier "-webkit-box").
if (mDidUnprefixWebkitBoxInEarlierDecl && keyword == eCSSKeyword__moz_box) {
MOZ_ASSERT(ShouldUseUnprefixingService(),
"mDidUnprefixWebkitBoxInEarlierDecl should only be set if "
"we're using the unprefixing service on this site");
return eCSSKeyword_flex;
}
}
return keyword;
}
bool
CSSParserImpl::ShouldUseUnprefixingService()
{
if (!sUnprefixingServiceEnabled) {
return false;
}
// XXXdholbert Bug 1132743: Check if stylesheet URI is on fixlist here.
return true;
}
bool
CSSParserImpl::ParsePropertyWithUnprefixingService(
const nsAString& aPropertyName,
css::Declaration* aDeclaration,
uint32_t aFlags,
bool aMustCallValueAppended,
bool* aChanged,
nsCSSContextType aContext)
{
MOZ_ASSERT(ShouldUseUnprefixingService(),
"Caller should've checked ShouldUseUnprefixingService()");
nsCOMPtr<nsICSSUnprefixingService> unprefixingSvc =
do_GetService(NS_CSSUNPREFIXINGSERVICE_CONTRACTID);
NS_ENSURE_TRUE(unprefixingSvc, false);
// Save the state so we can jump back to this spot if our unprefixing fails
// (so we can behave as if we didn't even try to unprefix).
nsAutoCSSParserInputStateRestorer parserStateBeforeTryingToUnprefix(this);
// Caller has already parsed the first half of the declaration --
// aPropertyName and the ":". Now, we record the rest of the CSS declaration
// (the part after ':') into rightHalfOfDecl. (This is the property value,
// plus anything else up to the end of the declaration -- maybe "!important",
// maybe trailing junk characters, maybe a semicolon, maybe a trailing "}".)
bool checkForBraces = (aFlags & eParseDeclaration_InBraces) != 0;
nsAutoString rightHalfOfDecl;
mScanner->StartRecording();
SkipDeclaration(checkForBraces);
mScanner->StopRecording(rightHalfOfDecl);
// Try to unprefix:
bool success;
nsAutoString unprefixedDecl;
nsresult rv =
unprefixingSvc->GenerateUnprefixedDeclaration(aPropertyName,
rightHalfOfDecl,
unprefixedDecl, &success);
if (NS_FAILED(rv) || !success) {
return false;
}
// Attempt to parse the unprefixed declaration:
nsAutoScannerChanger scannerChanger(this, unprefixedDecl);
success = ParseDeclaration(aDeclaration,
aFlags | eParseDeclaration_FromUnprefixingSvc,
aMustCallValueAppended, aChanged, aContext);
if (success) {
// We succeeded, so we'll leave the parser pointing at the end of
// the declaration; don't restore it to the pre-recording position.
parserStateBeforeTryingToUnprefix.DoNotRestore();
}
return success;
}
//----------------------------------------------------------------------
bool
@ -6763,19 +6530,7 @@ CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration,
(aContext == eCSSContext_Page &&
!nsCSSProps::PropHasFlags(propID,
CSS_PROPERTY_APPLIES_TO_PAGE_RULE))) { // unknown property
if (NonMozillaVendorIdentifier(propertyName)) {
if (!mInSupportsCondition &&
aContext == eCSSContext_General &&
!(aFlags & eParseDeclaration_FromUnprefixingSvc) && // no recursion
ShouldUseUnprefixingService()) {
if (ParsePropertyWithUnprefixingService(propertyName,
aDeclaration, aFlags,
aMustCallValueAppended,
aChanged, aContext)) {
return true;
}
}
} else {
if (!NonMozillaVendorIdentifier(propertyName)) {
REPORT_UNEXPECTED_P(PEUnknownProperty, propertyName);
REPORT_UNEXPECTED(PEDeclDropped);
OUTPUT_ERROR();
@ -7146,9 +6901,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
nsCSSToken* tk = &mToken;
if (((aVariantMask & (VARIANT_AHK | VARIANT_NORMAL | VARIANT_NONE | VARIANT_ALL)) != 0) &&
(eCSSToken_Ident == tk->mType)) {
nsCSSKeyword keyword = LookupKeywordPrefixAware(tk->mIdent,
aKeywordTable);
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(tk->mIdent);
if (eCSSKeyword_UNKNOWN < keyword) { // known keyword
if ((aVariantMask & VARIANT_AUTO) != 0) {
if (eCSSKeyword_auto == keyword) {
@ -15307,8 +15060,6 @@ nsCSSParser::Startup()
{
Preferences::AddBoolVarCache(&sOpentypeSVGEnabled,
"gfx.font_rendering.opentype_svg.enabled");
Preferences::AddBoolVarCache(&sUnprefixingServiceEnabled,
"layout.css.unprefixing-service.enabled");
}
nsCSSParser::nsCSSParser(mozilla::css::Loader* aLoader,

View File

@ -1,48 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* interface for a service that converts certain vendor-prefixed CSS properties
to their unprefixed equivalents */
#include "nsISupports.idl"
[scriptable, uuid(927a5c60-0378-4bcb-a50d-99e6d1fe6063)]
interface nsICSSUnprefixingService : nsISupports
{
/**
* This function helps to convert unsupported vendor-prefixed CSS into
* supported unprefixed CSS. Given a vendor-prefixed property name and a
* value (or e.g. value + trailing junk like " !important;}"), this function
* will attempt to produce an equivalent CSS declaration that uses a
* supported unprefixed CSS property.
*
* @param aPropName
* The vendor-prefixed property name.
*
* @param aRightHalfOfDecl
* Everything after the ":" in the CSS declaration. This includes
* the property's value, along with possibly some leading whitespace
* and trailing text like "!important", and possibly a ';' and/or
* '}' (along with any other bogus text the author happens to
* include before those, which will probably make the decl invalid).
*
* @param aUnprefixedDecl[out]
* The resulting unprefixed declaration, if we return true.
*
* @return true if we were able to unprefix -- i.e. if we were able to
* convert the property to a known unprefixed equivalent, and we also
* performed any known-to-be-necessary fixup on the value, and we put
* the result in aUnprefixedDecl.
* Otherwise, this function returns false.
*/
boolean generateUnprefixedDeclaration(in AString aPropName,
in AString aRightHalfOfDecl,
out AString aUnprefixedDecl);
};
%{C++
#define NS_CSSUNPREFIXINGSERVICE_CONTRACTID \
"@mozilla.org/css-unprefixing-service;1"
%}

View File

@ -223,7 +223,6 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 775227 # b2g(times out,
[test_units_frequency.html]
[test_units_length.html]
[test_units_time.html]
[test_unprefixing_service.html]
[test_value_cloning.html]
skip-if = (toolkit == 'gonk' && debug) || toolkit == 'android' #bug 775227 #debug-only failure; timed out
[test_value_computation.html]

View File

@ -1,240 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1107378
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1107378</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="property_database.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1107378">Mozilla Bug 1107378</a>
<div id="display">
<div id="content">
</div>
</div>
<pre id="test">
<script type="application/javascript;version=1.7">
"use strict";
/** Test for the CSS Unprefixing Service (Bug 1107378) **/
function getComputedStyleWrapper(elem, prop)
{
return window.getComputedStyle(elem, null).getPropertyValue(prop);
}
const gTestcases = [
{ decl: "-webkit-box-flex:5",
targetPropName: "flex-grow",
targetPropVal: "5" },
/* If author happens to specify modern flexbox style after prefixed style,
make sure the modern stuff is preserved. */
{ decl: "-webkit-box-flex:4;flex-grow:6",
targetPropName: "flex-grow",
targetPropVal: "6" },
/* Tests for handling !important: */
{ decl: "-webkit-box-flex:3!important;",
targetPropName: "flex-grow",
targetPropVal: "3" },
{ decl: "-webkit-box-flex:2!important;flex-grow:1",
targetPropName: "flex-grow",
targetPropVal: "2" },
{ decl: "-webkit-box-flex:1!important bogusText;",
targetPropName: "flex-grow"
/* invalid syntax --> no target prop-val. */
},
// Make sure we handle weird capitalization in property & value, too:
{ decl: "-WEBKIT-BoX-aLign: baSELine",
targetPropName: "align-items",
targetPropVal: "baseline" },
{ decl: "display:-webkit-box",
targetPropName: "display",
targetPropVal: "flex" },
{ decl: "display:-webkit-box; display:-moz-box;",
targetPropName: "display",
targetPropVal: "flex" },
{ decl: "display:-webkit-foobar; display:-moz-box;",
targetPropName: "display",
targetPropVal: "-moz-box" },
// -webkit-box-align: baseline | center | end | start | stretch
// ...maps to:
// align-items: baseline | center | flex-end | flex-start | stretch
{ decl: "-webkit-box-align: baseline",
targetPropName: "align-items",
targetPropVal: "baseline" },
{ decl: "-webkit-box-align: center",
targetPropName: "align-items",
targetPropVal: "center" },
{ decl: "-webkit-box-align: end",
targetPropName: "align-items",
targetPropVal: "flex-end" },
{ decl: "-webkit-box-align: start",
targetPropName: "align-items",
targetPropVal: "flex-start" },
{ decl: "-webkit-box-align: stretch",
targetPropName: "align-items",
targetPropVal: "stretch" },
// -webkit-box-direction is not supported, because it's unused & would be
// complicated to support. See note in CSSUnprefixingService.js for more.
// -webkit-box-ordinal-group: <number> maps directly to "order".
{ decl: "-webkit-box-ordinal-group: 2",
targetPropName: "order",
targetPropVal: "2" },
{ decl: "-webkit-box-ordinal-group: 6000",
targetPropName: "order",
targetPropVal: "6000" },
// -webkit-box-orient: horizontal | inline-axis | vertical | block-axis
// ...maps to:
// flex-direction: row | row | column | column
{ decl: "-webkit-box-orient: horizontal",
targetPropName: "flex-direction",
targetPropVal: "row" },
{ decl: "-webkit-box-orient: inline-axis",
targetPropName: "flex-direction",
targetPropVal: "row" },
{ decl: "-webkit-box-orient: vertical",
targetPropName: "flex-direction",
targetPropVal: "column" },
{ decl: "-webkit-box-orient: block-axis",
targetPropName: "flex-direction",
targetPropVal: "column" },
// -webkit-box-pack: start | center | end | justify
// ... maps to:
// justify-content: flex-start | center | flex-end | space-between
{ decl: "-webkit-box-pack: start",
targetPropName: "justify-content",
targetPropVal: "flex-start" },
{ decl: "-webkit-box-pack: center",
targetPropName: "justify-content",
targetPropVal: "center" },
{ decl: "-webkit-box-pack: end",
targetPropName: "justify-content",
targetPropVal: "flex-end" },
{ decl: "-webkit-box-pack: justify",
targetPropName: "justify-content",
targetPropVal: "space-between" },
// -webkit-transform: <transform> maps directly to "transform"
{ decl: "-webkit-transform: matrix(1, 2, 3, 4, 5, 6)",
targetPropName: "transform",
targetPropVal: "matrix(1, 2, 3, 4, 5, 6)" },
// -webkit-transition: <property> maps directly to "transition"
{ decl: "-webkit-transition: width 1s linear 2s",
targetPropName: "transition",
targetPropVal: "width 1s linear 2s" },
// -webkit-transition **with** -webkit-prefixed property in value.
{ decl: "-webkit-transition: -webkit-transform 1s linear 2s",
targetPropName: "transition",
targetPropVal: "transform 1s linear 2s" },
// (Re-test to check that it sets the "transition-property" subproperty.)
{ decl: "-webkit-transition: -webkit-transform 1s linear 2s",
targetPropName: "transition-property",
targetPropVal: "transform" },
// Same as previous test, except with "-webkit-transform" in the
// middle of the value instead of at the beginning (still valid):
{ decl: "-webkit-transition: 1s -webkit-transform linear 2s",
targetPropName: "transition",
targetPropVal: "transform 1s linear 2s" },
{ decl: "-webkit-transition: 1s -webkit-transform linear 2s",
targetPropName: "transition-property",
targetPropVal: "transform" },
];
// The main test function.
// aFlexboxTestcase is an entry from the list in flexbox_layout_testcases.js
function runOneTest(aTestcase)
{
let elem = document.getElementById("content");
let expectedValueInDOMStyle;
let expectedValueInComputedStyle;
if (typeof(aTestcase.targetPropVal) == 'undefined') {
expectedValueInDOMStyle = '';
expectedValueInComputedStyle = // initial computed style:
getComputedStyleWrapper(elem, aTestcase.targetPropName);
} else {
expectedValueInDOMStyle = aTestcase.targetPropVal;
expectedValueInComputedStyle = aTestcase.targetPropVal;
}
elem.setAttribute("style", aTestcase.decl);
// Check specified style for fixup:
is(elem.style[aTestcase.targetPropName], expectedValueInDOMStyle,
"Checking if unprefixing service produced expected result " +
"in elem.style['" + aTestcase.targetPropName + "'] " +
"when given decl '" + aTestcase.decl + "'");
// Check computed style for fixup:
// (only for longhand properties; shorthands aren't in computed style)
if (gCSSProperties[aTestcase.targetPropName].type == CSS_TYPE_LONGHAND) {
let computedValue = getComputedStyleWrapper(elem, aTestcase.targetPropName);
is(computedValue, expectedValueInComputedStyle,
"Checking if unprefixing service produced expected result " +
"in computed value of property '" + aTestcase.targetPropName + "' " +
"when given decl '" + aTestcase.decl + "'");
}
elem.setAttribute("style", "");
}
function testWithUnprefixingDisabled()
{
// Sanity-check that -webkit-prefixed properties are rejected, when
// pref is disabled:
let elem = document.getElementById("content");
let initialFlexGrow = getComputedStyleWrapper(elem, "flex-grow");
elem.setAttribute("style", "-webkit-box-flex:5");
is(getComputedStyleWrapper(elem, "flex-grow"), initialFlexGrow,
"-webkit-box-flex shouldn't affect 'flex-grow' " +
"when unprefixing pref is disabled");
let initialDisplay = getComputedStyleWrapper(elem, "display");
elem.setAttribute("style", "display:-webkit-box");
is(getComputedStyleWrapper(elem, "display"), initialDisplay,
"-webkit-box-flex shouldn't affect 'display' " +
"when unprefixing pref is disabled");
}
function testWithUnprefixingEnabled()
{
gTestcases.forEach(runOneTest);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
// First, test with unprefixing disabled (by default for now):
testWithUnprefixingDisabled();
// ...and then test with it enabled.
// XXXdholbert in bug 1132743, we'll be restricting unprefixing to only happen
// on a "fixlist" of domains. We'll need to run this test from a predetermined
// fake mochitest-domain, and include that domain in the "fixlist".
SpecialPowers.pushPrefEnv(
{ set: [["layout.css.unprefixing-service.enabled", true]] },
testWithUnprefixingEnabled);
</script>
</pre>
</body>
</html>

View File

@ -391,8 +391,6 @@
@BINPATH@/components/formautofill.manifest
@BINPATH@/components/FormAutofillContentService.js
@BINPATH@/components/FormAutofillStartup.js
@BINPATH@/components/CSSUnprefixingService.js
@BINPATH@/components/CSSUnprefixingService.manifest
@BINPATH@/components/contentAreaDropListener.manifest
@BINPATH@/components/contentAreaDropListener.js
@BINPATH@/components/messageWakeupService.js

View File

@ -2154,10 +2154,6 @@ pref("layout.css.prefixes.animations", true);
pref("layout.css.prefixes.box-sizing", true);
pref("layout.css.prefixes.font-features", true);
// Is the CSS Unprefixing Service enabled? (This service emulates support
// for certain vendor-prefixed properties & values, for sites on a "fixlist".)
pref("layout.css.unprefixing-service.enabled", false);
// Is support for the :scope selector enabled?
pref("layout.css.scope-pseudo.enabled", true);