mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1306007 - Part 1: Remove srcset/picture feature control preference; r=jdm,smaug
MozReview-Commit-ID: BsyTHeqiGZL --HG-- extra : rebase_source : 2add2510dbe16c641fe997a8349c1a36009bec20
This commit is contained in:
parent
df210784c6
commit
cf7304c3c6
@ -16,10 +16,6 @@
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsRuleData.h"
|
||||
|
||||
// For IsPictureEnabled() -- the candidate parser needs to be aware of sizes
|
||||
// support being enabled
|
||||
#include "HTMLPictureElement.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -557,8 +553,7 @@ ResponsiveImageDescriptors::AddDescriptor(const nsAString& aDescriptor)
|
||||
// If the value is not a valid non-negative integer, it doesn't match this
|
||||
// descriptor, fall through.
|
||||
if (ParseInteger(valueStr, possibleWidth) && possibleWidth >= 0) {
|
||||
if (possibleWidth != 0 && HTMLPictureElement::IsPictureEnabled() &&
|
||||
mWidth.isNothing() && mDensity.isNothing()) {
|
||||
if (possibleWidth != 0 && mWidth.isNothing() && mDensity.isNothing()) {
|
||||
mWidth.emplace(possibleWidth);
|
||||
} else {
|
||||
// Valid width descriptor, but width or density were already seen, sizes
|
||||
|
@ -50,12 +50,8 @@
|
||||
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
static const char *kPrefSrcsetEnabled = "dom.image.srcset.enabled";
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Image)
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -170,19 +166,9 @@ HTMLImageElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
||||
nsGenericHTMLElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLImageElement::IsSrcsetEnabled()
|
||||
{
|
||||
return Preferences::GetBool(kPrefSrcsetEnabled, false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLImageElement::GetCurrentSrc(nsAString& aValue)
|
||||
{
|
||||
if (!IsSrcsetEnabled()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
GetCurrentURI(getter_AddRefs(currentURI));
|
||||
if (currentURI) {
|
||||
@ -433,12 +419,10 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
CancelImageRequests(aNotify);
|
||||
}
|
||||
} else if (aName == nsGkAtoms::srcset &&
|
||||
aNameSpaceID == kNameSpaceID_None &&
|
||||
IsSrcsetEnabled()) {
|
||||
aNameSpaceID == kNameSpaceID_None) {
|
||||
PictureSourceSrcsetChanged(this, attrVal.String(), aNotify);
|
||||
} else if (aName == nsGkAtoms::sizes &&
|
||||
aNameSpaceID == kNameSpaceID_None &&
|
||||
HTMLPictureElement::IsPictureEnabled()) {
|
||||
aNameSpaceID == kNameSpaceID_None) {
|
||||
PictureSourceSizesChanged(this, attrVal.String(), aNotify);
|
||||
}
|
||||
|
||||
@ -929,14 +913,10 @@ HTMLImageElement::QueueImageLoadTask(bool aAlwaysLoad)
|
||||
bool
|
||||
HTMLImageElement::HaveSrcsetOrInPicture()
|
||||
{
|
||||
if (IsSrcsetEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) {
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!HTMLPictureElement::IsPictureEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Element *parent = nsINode::GetParentElement();
|
||||
return (parent && parent->IsHTMLElement(nsGkAtoms::picture));
|
||||
}
|
||||
@ -1027,14 +1007,8 @@ HTMLImageElement::PictureSourceSrcsetChanged(nsIContent *aSourceNode,
|
||||
const nsAString& aNewValue,
|
||||
bool aNotify)
|
||||
{
|
||||
bool isSelf = aSourceNode == this;
|
||||
|
||||
if (!IsSrcsetEnabled() ||
|
||||
(!isSelf && !HTMLPictureElement::IsPictureEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(isSelf || IsPreviousSibling(aSourceNode, this),
|
||||
MOZ_ASSERT(aSourceNode == this ||
|
||||
IsPreviousSibling(aSourceNode, this),
|
||||
"Should not be getting notifications for non-previous-siblings");
|
||||
|
||||
nsIContent *currentSrc =
|
||||
@ -1064,10 +1038,6 @@ HTMLImageElement::PictureSourceSizesChanged(nsIContent *aSourceNode,
|
||||
const nsAString& aNewValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (!HTMLPictureElement::IsPictureEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSourceNode == this ||
|
||||
IsPreviousSibling(aSourceNode, this),
|
||||
"Should not be getting notifications for non-previous-siblings");
|
||||
@ -1090,10 +1060,6 @@ void
|
||||
HTMLImageElement::PictureSourceMediaOrTypeChanged(nsIContent *aSourceNode,
|
||||
bool aNotify)
|
||||
{
|
||||
if (!HTMLPictureElement::IsPictureEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(IsPreviousSibling(aSourceNode, this),
|
||||
"Should not be getting notifications for non-previous-siblings");
|
||||
|
||||
@ -1105,10 +1071,6 @@ HTMLImageElement::PictureSourceMediaOrTypeChanged(nsIContent *aSourceNode,
|
||||
void
|
||||
HTMLImageElement::PictureSourceAdded(nsIContent *aSourceNode)
|
||||
{
|
||||
if (!HTMLPictureElement::IsPictureEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSourceNode == this ||
|
||||
IsPreviousSibling(aSourceNode, this),
|
||||
"Should not be getting notifications for non-previous-siblings");
|
||||
@ -1119,10 +1081,6 @@ HTMLImageElement::PictureSourceAdded(nsIContent *aSourceNode)
|
||||
void
|
||||
HTMLImageElement::PictureSourceRemoved(nsIContent *aSourceNode)
|
||||
{
|
||||
if (!HTMLPictureElement::IsPictureEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSourceNode == this ||
|
||||
IsPreviousSibling(aSourceNode, this),
|
||||
"Should not be getting notifications for non-previous-siblings");
|
||||
@ -1135,15 +1093,9 @@ HTMLImageElement::UpdateResponsiveSource()
|
||||
{
|
||||
bool hadSelector = !!mResponsiveSelector;
|
||||
|
||||
if (!IsSrcsetEnabled()) {
|
||||
mResponsiveSelector = nullptr;
|
||||
return hadSelector;
|
||||
}
|
||||
|
||||
nsIContent *currentSource =
|
||||
mResponsiveSelector ? mResponsiveSelector->Content() : nullptr;
|
||||
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
|
||||
Element *parent = pictureEnabled ? nsINode::GetParentElement() : nullptr;
|
||||
Element *parent = nsINode::GetParentElement();
|
||||
|
||||
nsINode *candidateSource = nullptr;
|
||||
if (parent && parent->IsHTMLElement(nsGkAtoms::picture)) {
|
||||
@ -1231,7 +1183,6 @@ HTMLImageElement::SourceElementMatches(nsIContent* aSourceNode)
|
||||
DebugOnly<Element *> parent(nsINode::GetParentElement());
|
||||
MOZ_ASSERT(parent && parent->IsHTMLElement(nsGkAtoms::picture));
|
||||
MOZ_ASSERT(IsPreviousSibling(aSourceNode, this));
|
||||
MOZ_ASSERT(HTMLPictureElement::IsPictureEnabled());
|
||||
|
||||
// Check media and type
|
||||
HTMLSourceElement *src = static_cast<HTMLSourceElement*>(aSourceNode);
|
||||
@ -1253,11 +1204,6 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
|
||||
const nsAString *aSrcset,
|
||||
const nsAString *aSizes)
|
||||
{
|
||||
if (!IsSrcsetEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
|
||||
// Skip if this is not a <source> with matching media query
|
||||
bool isSourceTag = aSourceNode->IsHTMLElement(nsGkAtoms::source);
|
||||
if (isSourceTag) {
|
||||
@ -1290,9 +1236,9 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pictureEnabled && aSizes) {
|
||||
if (aSizes) {
|
||||
sel->SetSizesFromDescriptor(*aSizes);
|
||||
} else if (pictureEnabled) {
|
||||
} else {
|
||||
nsAutoString sizes;
|
||||
aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::sizes, sizes);
|
||||
sel->SetSizesFromDescriptor(sizes);
|
||||
@ -1326,12 +1272,7 @@ HTMLImageElement::SelectSourceForTagWithAttrs(nsIDocument *aDocument,
|
||||
MOZ_ASSERT(!aIsSourceTag || aSrcAttr.IsEmpty(),
|
||||
"Passing aSrcAttr makes no sense with aIsSourceTag set");
|
||||
|
||||
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
|
||||
if (aIsSourceTag && !pictureEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsSrcsetEnabled() || aSrcsetAttr.IsEmpty()) {
|
||||
if (aSrcsetAttr.IsEmpty()) {
|
||||
if (!aIsSourceTag) {
|
||||
// For an <img> with no srcset, we would always select the src attr.
|
||||
aResult.Assign(aSrcAttr);
|
||||
@ -1355,7 +1296,7 @@ HTMLImageElement::SelectSourceForTagWithAttrs(nsIDocument *aDocument,
|
||||
new ResponsiveImageSelector(aDocument);
|
||||
|
||||
sel->SetCandidatesFromSourceSet(aSrcsetAttr);
|
||||
if (pictureEnabled && !aSizesAttr.IsEmpty()) {
|
||||
if (!aSizesAttr.IsEmpty()) {
|
||||
sel->SetSizesFromDescriptor(aSizesAttr);
|
||||
}
|
||||
if (!aIsSourceTag) {
|
||||
|
@ -15,9 +15,6 @@
|
||||
#include "Units.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
// Only needed for IsPictureEnabled()
|
||||
#include "mozilla/dom/HTMLPictureElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
class EventChainPreVisitor;
|
||||
namespace dom {
|
||||
@ -97,8 +94,6 @@ public:
|
||||
|
||||
void MaybeLoadImage();
|
||||
|
||||
static bool IsSrcsetEnabled();
|
||||
|
||||
bool IsMap()
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::ismap);
|
||||
|
@ -8,18 +8,11 @@
|
||||
#include "mozilla/dom/HTMLPictureElementBinding.h"
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
static const char *kPrefPictureEnabled = "dom.image.picture.enabled";
|
||||
|
||||
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Picture) to add pref check.
|
||||
nsGenericHTMLElement*
|
||||
NS_NewHTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser)
|
||||
{
|
||||
if (!mozilla::dom::HTMLPictureElement::IsPictureEnabled()) {
|
||||
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
|
||||
}
|
||||
|
||||
return new mozilla::dom::HTMLPictureElement(aNodeInfo);
|
||||
}
|
||||
|
||||
@ -95,13 +88,6 @@ HTMLPictureElement::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotif
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLPictureElement::IsPictureEnabled()
|
||||
{
|
||||
return HTMLImageElement::IsSrcsetEnabled() &&
|
||||
Preferences::GetBool(kPrefPictureEnabled, false);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLPictureElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "nsIDOMHTMLPictureElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
#include "mozilla/dom/HTMLUnknownElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -32,8 +30,6 @@ public:
|
||||
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify) override;
|
||||
|
||||
static bool IsPictureEnabled();
|
||||
|
||||
protected:
|
||||
virtual ~HTMLPictureElement();
|
||||
|
||||
|
@ -71,7 +71,7 @@ load 903106.html
|
||||
load 916322-1.html
|
||||
load 916322-2.html
|
||||
load 1032654.html
|
||||
pref(dom.image.srcset.enabled,true) load 1141260.html
|
||||
load 1141260.html
|
||||
load 1228876.html
|
||||
load 1230110.html
|
||||
load 1237633.html
|
||||
|
@ -48,8 +48,8 @@ skip == bug917595-exif-rotated.jpg bug917595-exif-rotated.jpg
|
||||
# Bug 1150490 disabling on Mulet as on B2G
|
||||
|
||||
# Test support for SVG-as-image in <picture> elements.
|
||||
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-1.html
|
||||
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-2.html
|
||||
== bug1106522-1.html bug1106522-1.html
|
||||
== bug1106522-2.html bug1106522-2.html
|
||||
|
||||
== href-attr-change-restyles.html href-attr-change-restyles.html
|
||||
== figure.html figure.html
|
||||
|
@ -44,8 +44,8 @@ fuzzy(1,149) == bug917595-iframe-1.html bug917595-1-ref.html
|
||||
skip-if(B2G||Mulet) fuzzy-if((!B2G&&!Mulet),3,640) == bug917595-exif-rotated.jpg bug917595-pixel-rotated.jpg # bug 1060869 # Bug 1150490 disabling on Mulet as on B2G
|
||||
|
||||
# Test support for SVG-as-image in <picture> elements.
|
||||
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-ref.html
|
||||
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-ref.html
|
||||
== bug1106522-1.html bug1106522-ref.html
|
||||
== bug1106522-2.html bug1106522-ref.html
|
||||
|
||||
== href-attr-change-restyles.html href-attr-change-restyles-ref.html
|
||||
== figure.html figure-ref.html
|
||||
|
@ -166,16 +166,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
SpecialPowers.pushPrefEnv({'set': [["security.mixed_content.use_hsts", false],
|
||||
["security.mixed_content.send_hsts_priming", false]]});
|
||||
//Set the first set of mixed content settings and increment the counter.
|
||||
//Enable <picture> and <img srcset> for the test.
|
||||
changePrefs([[ "dom.image.srcset.enabled", true ], [ "dom.image.picture.enabled", true ]],
|
||||
function() {
|
||||
//listen for a messages from the mixed content test harness
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
changePrefs([], function() {
|
||||
//listen for a messages from the mixed content test harness
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
//Kick off test
|
||||
reloadFrame();
|
||||
}
|
||||
);
|
||||
//Kick off test
|
||||
reloadFrame();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -100,14 +100,12 @@ skip-if = buildapp == 'mulet'
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_performance_timeline.html]
|
||||
[test_picture_mutations.html]
|
||||
[test_picture_pref.html]
|
||||
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
|
||||
[test_resource_timing.html]
|
||||
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
|
||||
[test_resource_timing_cross_origin.html]
|
||||
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
|
||||
[test_performance_now.html]
|
||||
[test_srcset_pref.html]
|
||||
[test_showModalDialog.html]
|
||||
skip-if = e10s || buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #Don't run modal tests on Android # b2g(showmodaldialog) b2g-debug(showmodaldialog) b2g-desktop(showmodaldialog)
|
||||
[test_showModalDialog_e10s.html]
|
||||
|
@ -218,8 +218,7 @@
|
||||
}
|
||||
|
||||
addEventListener("load", function() {
|
||||
SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0"],
|
||||
[ "dom.image.srcset.enabled", true ]] },
|
||||
SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0"]] },
|
||||
function() {
|
||||
// Create this after the pref is set, as it is guarding webIDL attributes
|
||||
img = document.createElement("img");
|
||||
|
@ -293,9 +293,7 @@
|
||||
}
|
||||
|
||||
addEventListener("load", function() {
|
||||
SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0" ],
|
||||
[ "dom.image.srcset.enabled", true ],
|
||||
[ "dom.image.picture.enabled", true ]] },
|
||||
SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0" ]] },
|
||||
function() {
|
||||
// Create these after the pref is set, as it is guarding webIDL attributes
|
||||
img = document.createElement("img");
|
||||
|
@ -1,108 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=870022
|
||||
-->
|
||||
<head>
|
||||
<title>Test for dom.image.picture.enabled (Bug 870022)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="setupTest()">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870022">Mozilla Bug 870022</a>
|
||||
|
||||
<!-- Tests that the picture pref can still be disabled, accounting
|
||||
for dom.images.srcset.enabled being flipped on in the mean time. -->
|
||||
|
||||
<!-- these should all load red.png (naturalWidth 1) not big.png (natural
|
||||
width 3000) regardless of dom.images.srcset.enabled being on or off -->
|
||||
|
||||
<div id="testContainer">
|
||||
<picture>
|
||||
<source srcset="http://example.com/tests/image/test/mochitest/big.png">
|
||||
<img id="img1" src="http://example.com/tests/image/test/mochitest/red.png">
|
||||
</picture>
|
||||
|
||||
<picture>
|
||||
<source srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
|
||||
sizes="500w">
|
||||
<img id="img2"
|
||||
src="http://example.com/tests/image/test/mochitest/red.png"
|
||||
srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
|
||||
sizes="50px">
|
||||
</picture>
|
||||
|
||||
<!-- Should load red.png with srcset on, otherwise nothing -->
|
||||
<img id="img-srcset-only"
|
||||
srcset="http://example.com/tests/image/test/mochitest/big.png 500w, http://example.com/tests/image/test/mochitest/red.png 1x"
|
||||
sizes="50px">
|
||||
|
||||
<!-- Should not load regardless of srcset pref -->
|
||||
<img id="img-never"
|
||||
srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
|
||||
sizes="50px">
|
||||
</div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
const srcsetPref = 'dom.image.srcset.enabled';
|
||||
const picturePref = 'dom.image.picture.enabled';
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var srcsetEnabled = SpecialPowers.getBoolPref(srcsetPref);
|
||||
var pictureEnabled = SpecialPowers.getBoolPref(picturePref);
|
||||
|
||||
is(pictureEnabled, true, "picture expected to be enabled by default");
|
||||
|
||||
function setupTest() {
|
||||
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.picture.enabled", false ]] }, function() {
|
||||
var container = document.querySelector("#testContainer");
|
||||
// We want to re-create the elements with the pref disabled to ensure
|
||||
// webIDL attributes are not attached
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.addEventListener("load", function() {
|
||||
runTest(iframe);
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
iframe.src = "data:text/html;base64," + btoa(container.innerHTML);
|
||||
});
|
||||
}
|
||||
|
||||
function runTest(iframe) {
|
||||
var doc = iframe.contentDocument;
|
||||
var win = iframe.contentWindow;
|
||||
var img = doc.querySelector("img");
|
||||
var source = doc.querySelector("source");
|
||||
|
||||
is(img.sizes, undefined, "sizes should not be visible on <img>");
|
||||
is(source.sizes, undefined, "sizes should not be visible on <source>");
|
||||
is(source.srcset, undefined, "srcset should not be visible on <source>");
|
||||
|
||||
var imgSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLImageElement.prototype, "sizes");
|
||||
var sourceSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "sizes");
|
||||
var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "srcset");
|
||||
is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes");
|
||||
is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes");
|
||||
is(sourceSrcsetDesc, undefined, "HTMLSourceElement should know nothing of srcset");
|
||||
|
||||
// Make sure the test images loaded red.png, which is 1x1, not big.png
|
||||
for (var id of [ 'img1', 'img2' ]) {
|
||||
var testImg = doc.getElementById(id);
|
||||
is(testImg.naturalWidth, 1, "Image should have loaded small source");
|
||||
}
|
||||
|
||||
var srcsetOnlyImg = doc.getElementById("img-srcset-only");
|
||||
is(srcsetOnlyImg.naturalWidth, srcsetEnabled ? 1 : 0,
|
||||
"srcset image should only load if srcset is enabled, and never the computed width candidate");
|
||||
|
||||
var neverImg = doc.getElementById("img-never");
|
||||
is(neverImg.naturalWidth, 0, "Image should not have loaded");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,59 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=870021
|
||||
-->
|
||||
<head>
|
||||
<title>Test for dom.image.srcset.enabled (Bug 870021)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="setupTest()">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870021">Mozilla Bug 870021</a>
|
||||
|
||||
<div id="imgContainer">
|
||||
</div>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
const srcsetPref = 'dom.image.srcset.enabled';
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
is(SpecialPowers.getBoolPref(srcsetPref), true, "srcset should be enabled by default");
|
||||
|
||||
function setupTest() {
|
||||
// Ensure that disabling the pref works as expected
|
||||
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() {
|
||||
var container = document.querySelector("#imgContainer");
|
||||
|
||||
var img = document.createElement("img");
|
||||
img.setAttribute("src", "http://example.com/tests/image/test/mochitest/blue.png");
|
||||
img.setAttribute("srcset", "http://example.com/tests/image/test/mochitest/big.png");
|
||||
container.insertBefore(img, container.firstChild);
|
||||
img.addEventListener("load", function imgLoad() {
|
||||
img.removeEventListener("load", imgLoad);
|
||||
runTest();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var img = document.querySelector("img");
|
||||
is(img.currentSrc, undefined, "currentSrc should not be visible");
|
||||
is(img.srcset, undefined, "srcset should not be visible");
|
||||
|
||||
var currentSrcDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "currentSrc");
|
||||
var srcsetDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "srcset");
|
||||
is(currentSrcDesc, undefined, "HTMLImageElement should know nothing of currentSrc");
|
||||
is(srcsetDesc, undefined, "HTMLImageElement should know nothing of srcset");
|
||||
|
||||
// Make sure the test image loaded the src image, which is 1x1, not the srcset image
|
||||
is(img.naturalWidth, 1, "Image should have loaded small source");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -22,7 +22,7 @@ interface HTMLImageElement : HTMLElement {
|
||||
attribute DOMString alt;
|
||||
[SetterThrows]
|
||||
attribute DOMString src;
|
||||
[SetterThrows, Pref="dom.image.srcset.enabled"]
|
||||
[SetterThrows]
|
||||
attribute DOMString srcset;
|
||||
[SetterThrows]
|
||||
attribute DOMString? crossOrigin;
|
||||
@ -60,9 +60,8 @@ partial interface HTMLImageElement {
|
||||
// [Update me: not in whatwg spec yet]
|
||||
// http://picture.responsiveimages.org/#the-img-element
|
||||
partial interface HTMLImageElement {
|
||||
[SetterThrows, Pref="dom.image.picture.enabled"]
|
||||
[SetterThrows]
|
||||
attribute DOMString sizes;
|
||||
[Pref="dom.image.srcset.enabled"]
|
||||
readonly attribute DOMString currentSrc;
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,5 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Pref="dom.image.picture.enabled"]
|
||||
interface HTMLPictureElement : HTMLElement {
|
||||
};
|
||||
|
@ -19,9 +19,9 @@ interface HTMLSourceElement : HTMLElement {
|
||||
};
|
||||
|
||||
partial interface HTMLSourceElement {
|
||||
[SetterThrows, Pref="dom.image.picture.enabled"]
|
||||
[SetterThrows]
|
||||
attribute DOMString srcset;
|
||||
[SetterThrows, Pref="dom.image.picture.enabled"]
|
||||
[SetterThrows]
|
||||
attribute DOMString sizes;
|
||||
[SetterThrows]
|
||||
attribute DOMString media;
|
||||
|
@ -66,8 +66,6 @@ onload = function() {
|
||||
["browser.send_pings", true],
|
||||
["browser.send_pings.max_per_link", -1],
|
||||
["dom.caches.enabled", true],
|
||||
["dom.image.picture.enabled", true],
|
||||
["dom.image.srcset.enabled", true],
|
||||
["dom.requestcontext.enabled", true],
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
|
@ -121,17 +121,17 @@ skip == image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selectio
|
||||
skip == image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x.html
|
||||
skip == image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x.html
|
||||
skip == image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-2x.html image-srcset-default-2x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-1x.html image-srcset-default-1x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-src-2x.html image-srcset-default-src-2x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-src-1x.html image-srcset-default-src-1x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-orientation-2x.html image-srcset-orientation-2x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-orientation-1x.html image-srcset-orientation-1x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-3x.html image-srcset-svg-3x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-2x.html image-srcset-svg-2x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-1x.html image-srcset-svg-1x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-2x.html image-srcset-svg-default-2x.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-1x.html image-srcset-svg-default-1x.html
|
||||
== image-srcset-default-2x.html image-srcset-default-2x.html
|
||||
== image-srcset-default-1x.html image-srcset-default-1x.html
|
||||
== image-srcset-default-src-2x.html image-srcset-default-src-2x.html
|
||||
== image-srcset-default-src-1x.html image-srcset-default-src-1x.html
|
||||
== image-srcset-orientation-2x.html image-srcset-orientation-2x.html
|
||||
== image-srcset-orientation-1x.html image-srcset-orientation-1x.html
|
||||
== image-srcset-svg-3x.html image-srcset-svg-3x.html
|
||||
== image-srcset-svg-2x.html image-srcset-svg-2x.html
|
||||
== image-srcset-svg-1x.html image-srcset-svg-1x.html
|
||||
== image-srcset-svg-default-2x.html image-srcset-svg-default-2x.html
|
||||
== image-srcset-svg-default-1x.html image-srcset-svg-default-1x.html
|
||||
|
||||
== image-resize-percent-height.html image-resize-percent-height.html
|
||||
== image-resize-percent-width.html image-resize-percent-width.html
|
||||
|
@ -102,27 +102,27 @@ fuzzy(1,1) == image-orientation-background.html?90&flip image-orientation-r
|
||||
== image-orientation-dynamic.html image-orientation-dynamic-ref.html
|
||||
|
||||
# <img srcset> tests
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.1x.html image-srcset-basic-selection-0.1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-2x.html image-srcset-basic-selection-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.5x.html image-srcset-basic-selection-0.5x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.6x.html image-srcset-basic-selection-0.6x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-1.5x.html image-srcset-basic-selection-1.5x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-1x.html image-srcset-basic-selection-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selection-width-0.5x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-2x.html image-srcset-default-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-1x.html image-srcset-default-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-src-2x.html image-srcset-default-src-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-default-src-1x.html image-srcset-default-src-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-orientation-2x.html image-srcset-orientation-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-orientation-1x.html image-srcset-orientation-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-3x.html image-srcset-svg-3x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-2x.html image-srcset-svg-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-1x.html image-srcset-svg-1x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-2x.html image-srcset-svg-default-2x-ref.html
|
||||
pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-1x.html image-srcset-svg-default-1x-ref.html
|
||||
== image-srcset-basic-selection-0.1x.html image-srcset-basic-selection-0.1x-ref.html
|
||||
== image-srcset-basic-selection-2x.html image-srcset-basic-selection-2x-ref.html
|
||||
== image-srcset-basic-selection-0.5x.html image-srcset-basic-selection-0.5x-ref.html
|
||||
== image-srcset-basic-selection-0.6x.html image-srcset-basic-selection-0.6x-ref.html
|
||||
== image-srcset-basic-selection-1.5x.html image-srcset-basic-selection-1.5x-ref.html
|
||||
== image-srcset-basic-selection-1x.html image-srcset-basic-selection-1x-ref.html
|
||||
== image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selection-width-0.5x-ref.html
|
||||
== image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x-ref.html
|
||||
== image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x-ref.html
|
||||
== image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x-ref.html
|
||||
== image-srcset-default-2x.html image-srcset-default-2x-ref.html
|
||||
== image-srcset-default-1x.html image-srcset-default-1x-ref.html
|
||||
== image-srcset-default-src-2x.html image-srcset-default-src-2x-ref.html
|
||||
== image-srcset-default-src-1x.html image-srcset-default-src-1x-ref.html
|
||||
== image-srcset-orientation-2x.html image-srcset-orientation-2x-ref.html
|
||||
== image-srcset-orientation-1x.html image-srcset-orientation-1x-ref.html
|
||||
== image-srcset-svg-3x.html image-srcset-svg-3x-ref.html
|
||||
== image-srcset-svg-2x.html image-srcset-svg-2x-ref.html
|
||||
== image-srcset-svg-1x.html image-srcset-svg-1x-ref.html
|
||||
== image-srcset-svg-default-2x.html image-srcset-svg-default-2x-ref.html
|
||||
== image-srcset-svg-default-1x.html image-srcset-svg-default-1x-ref.html
|
||||
|
||||
== image-resize-percent-height.html image-resize-ref.html
|
||||
== image-resize-percent-width.html image-resize-ref.html
|
||||
|
@ -4728,12 +4728,6 @@ pref("dom.vibrator.max_vibrate_list_len", 128);
|
||||
// Battery API
|
||||
pref("dom.battery.enabled", true);
|
||||
|
||||
// Image srcset
|
||||
pref("dom.image.srcset.enabled", true);
|
||||
|
||||
// <picture> element and sizes
|
||||
pref("dom.image.picture.enabled", true);
|
||||
|
||||
// WebSMS
|
||||
pref("dom.sms.enabled", false);
|
||||
// Enable Latin characters replacement with corresponding ones in GSM SMS
|
||||
|
Loading…
Reference in New Issue
Block a user