mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-09 09:58:57 +00:00
61 lines
2.2 KiB
HTML
61 lines
2.2 KiB
HTML
<!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">
|
|
<img src="http://example.com/tests/image/test/mochitest/blue.png"
|
|
srcset="http://example.com/tests/image/test/mochitest/big.png">
|
|
</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");
|
|
// We want to re-create the element with the pref disabled to ensure
|
|
// webIDL attributes are not attached
|
|
container.innerHTML = container.innerHTML + " ";
|
|
var img = container.querySelector("img");
|
|
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>
|