Skip to content

Commit

Permalink
Bug 984778 - Make hasFeature() and SVG requiredFeatures always return…
Browse files Browse the repository at this point in the history
… true; r=bz,longsonr

hasFeature() always returning true matches the current DOM spec.  SVG 2
has removed requiredFeatures.  Chrome has had both of these always
return true since 2014, and they seem to have had no problems.

Even requiredFeatures="" (empty string) now returns true, matching
Chrome.

MozReview-Commit-ID: 1LEu3iK4R94
  • Loading branch information
ayg committed Sep 1, 2016
1 parent db36da7 commit 0c1d714
Show file tree
Hide file tree
Showing 35 changed files with 32 additions and 493 deletions.
11 changes: 1 addition & 10 deletions dom/base/DOMImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,12 @@ DOMImplementation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return DOMImplementationBinding::Wrap(aCx, this, aGivenProto);
}

bool
DOMImplementation::HasFeature(const nsAString& aFeature,
const nsAString& aVersion)
{
return nsContentUtils::InternalIsSupported(
static_cast<nsIDOMDOMImplementation*>(this),
aFeature, aVersion);
}

NS_IMETHODIMP
DOMImplementation::HasFeature(const nsAString& aFeature,
const nsAString& aVersion,
bool* aReturn)
{
*aReturn = HasFeature(aFeature, aVersion);
*aReturn = true;
return NS_OK;
}

Expand Down
5 changes: 4 additions & 1 deletion dom/base/DOMImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class DOMImplementation final : public nsIDOMDOMImplementation
// nsIDOMDOMImplementation
NS_DECL_NSIDOMDOMIMPLEMENTATION

bool HasFeature(const nsAString& aFeature, const nsAString& aVersion);
bool HasFeature()
{
return true;
}

already_AddRefed<DocumentType>
CreateDocumentType(const nsAString& aQualifiedName,
Expand Down
1 change: 0 additions & 1 deletion dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
#include "nsCSSParser.h"
#include "prprf.h"
#include "nsDOMMutationObserver.h"
#include "nsSVGFeatures.h"
#include "nsWrapperCacheInlines.h"
#include "xpcpublic.h"
#include "nsIScriptError.h"
Expand Down
23 changes: 0 additions & 23 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
#include "nsSandboxFlags.h"
#include "nsScriptSecurityManager.h"
#include "nsStreamUtils.h"
#include "nsSVGFeatures.h"
#include "nsTextEditorState.h"
#include "nsTextFragment.h"
#include "nsTextNode.h"
Expand Down Expand Up @@ -6992,28 +6991,6 @@ nsContentUtils::GetHTMLEditor(nsPresContext* aPresContext)
return editor;
}

bool
nsContentUtils::InternalIsSupported(nsISupports* aObject,
const nsAString& aFeature,
const nsAString& aVersion)
{
// If it looks like an SVG feature string, forward to nsSVGFeatures
if (StringBeginsWith(aFeature,
NS_LITERAL_STRING("http://www.w3.org/TR/SVG"),
nsASCIICaseInsensitiveStringComparator()) ||
StringBeginsWith(aFeature, NS_LITERAL_STRING("org.w3c.dom.svg"),
nsASCIICaseInsensitiveStringComparator()) ||
StringBeginsWith(aFeature, NS_LITERAL_STRING("org.w3c.svg"),
nsASCIICaseInsensitiveStringComparator())) {
return (aVersion.IsEmpty() || aVersion.EqualsLiteral("1.0") ||
aVersion.EqualsLiteral("1.1")) &&
nsSVGFeatures::HasFeature(aObject, aFeature);
}

// Otherwise, we claim to support everything
return true;
}

bool
nsContentUtils::IsContentInsertionPoint(const nsIContent* aContent)
{
Expand Down
12 changes: 0 additions & 12 deletions dom/base/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2363,18 +2363,6 @@ class nsContentUtils

static nsIEditor* GetHTMLEditor(nsPresContext* aPresContext);

/**
* Check whether a spec feature/version is supported.
* @param aObject the object, which should support the feature,
* for example nsIDOMNode or nsIDOMDOMImplementation
* @param aFeature the feature ("Views", "Core", "HTML", "Range" ...)
* @param aVersion the version ("1.0", "2.0", ...)
* @return whether the feature is supported or not
*/
static bool InternalIsSupported(nsISupports* aObject,
const nsAString& aFeature,
const nsAString& aVersion);

/**
* Returns true if the browser.dom.window.dump.enabled pref is set.
*/
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsINode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
#include "nsRuleProcessorData.h"
#include "nsString.h"
#include "nsStyleConsts.h"
#include "nsSVGFeatures.h"
#include "nsSVGUtils.h"
#include "nsTextNode.h"
#include "nsUnicharUtils.h"
Expand Down
12 changes: 5 additions & 7 deletions dom/smil/test/test_smilConditionalProcessing.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
is(b.getStartTime(), 100, "b has resolved start time at start");

// Add a failing conditional processing test
a.setAttribute("requiredFeatures",
"http://www.w3.org/TR/SVGX/feature#SharksWithLasers");
a.setAttribute("systemLanguage", "no-such-language");
ok(hasUnresolvedStartTime(a),
"a has unresolved start time with failing conditional processing test");
is(circle.cy.animVal.value, 0,
Expand All @@ -41,15 +40,15 @@
"b has unresolved start time with failing conditional processing test on a");

// Remove failing conditional processing test
a.removeAttribute("requiredFeatures");
a.removeAttribute("systemLanguage");
is(a.getStartTime(), 0, "a has resolved start time after removing test");
is(circle.cy.animVal.value, 100, "a is in effect after removing test");
is(b.getStartTime(), 100, "b has resolved start time after removing test on a");

// Add another failing conditional processing test
// According to the spec, if a null string or empty string value is set for
// the 'requiredFeatures' attribute, the attribute returns "false".
a.setAttribute("requiredFeatures", "");
// the 'systemLanguage' attribute, the attribute returns "false".
a.setAttribute("systemLanguage", "");

// Fast forward until |a| would have finished
var endEventsReceived = 0;
Expand All @@ -61,8 +60,7 @@
"b is not in effect with failing conditional processing test on a");

// Make test pass
a.setAttribute("requiredFeatures",
"http://www.w3.org/TR/SVG11/feature#Animation");
a.setAttribute("systemLanguage", "en");
is(circle.cx.animVal.value, 100,
"b is in effect with passing conditional processing test on a");

Expand Down
15 changes: 0 additions & 15 deletions dom/svg/SVGTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,6 @@ const nsString * const SVGTests::kIgnoreSystemLanguage = (nsString *) 0x01;
bool
SVGTests::PassesConditionalProcessingTests(const nsString *aAcceptLangs) const
{
// Required Features
if (mStringListAttributes[FEATURES].IsExplicitlySet()) {
if (mStringListAttributes[FEATURES].IsEmpty()) {
return false;
}
nsCOMPtr<nsIContent> content(
do_QueryInterface(const_cast<SVGTests*>(this)));

for (uint32_t i = 0; i < mStringListAttributes[FEATURES].Length(); i++) {
if (!nsSVGFeatures::HasFeature(content, mStringListAttributes[FEATURES][i])) {
return false;
}
}
}

// Required Extensions
//
// The requiredExtensions attribute defines a list of required language
Expand Down
22 changes: 0 additions & 22 deletions dom/svg/nsSVGFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,6 @@

using namespace mozilla;

/*static*/ bool
nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature)
{
if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
if (content) {
nsIDocument* doc = content->GetUncomposedDoc();
if (doc && doc->IsResourceDoc()) {
// no scripting in SVG images or external resource documents
return false;
}
}
return Preferences::GetBool("javascript.enabled", false);
}
#define SVG_SUPPORTED_FEATURE(str) if (aFeature.EqualsLiteral(str)) return true;
#define SVG_UNSUPPORTED_FEATURE(str)
#include "nsSVGFeaturesList.h"
#undef SVG_SUPPORTED_FEATURE
#undef SVG_UNSUPPORTED_FEATURE
return false;
}

/*static*/ bool
nsSVGFeatures::HasExtension(const nsAString& aExtension, const bool aIsInChrome)
{
Expand Down
11 changes: 0 additions & 11 deletions dom/svg/nsSVGFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@
class nsSVGFeatures
{
public:
/**
* Check whether we support the given feature string.
*
* @param aObject the object, which should support the feature,
* for example nsIDOMNode or nsIDOMDOMImplementation
* @param aFeature one of the feature strings specified at
* http://www.w3.org/TR/SVG11/feature.html
*/
static bool
HasFeature(nsISupports* aObject, const nsAString& aFeature);

/**
* Check whether we support the given extension string.
*
Expand Down
76 changes: 0 additions & 76 deletions dom/svg/nsSVGFeaturesList.h

This file was deleted.

1 change: 0 additions & 1 deletion dom/svg/test/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ support-files =
[test_getCTM.html]
[test_getElementById.xhtml]
[test_getSubStringLength.xhtml]
[test_hasFeature.xhtml]
[test_lang.xhtml]
skip-if = true # disabled-for-intermittent-failures--bug-701060
[test_length.xhtml]
Expand Down
Loading

0 comments on commit 0c1d714

Please sign in to comment.