зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1431601 - Rewrite test_meta_viewportX.html with add_task. r=botond
Depends on D8318 Differential Revision: https://phabricator.services.mozilla.com/D8319 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c43cc6396c
Коммит
d513867baa
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script src="viewport_helpers.js"></script>
|
||||
</head>
|
||||
|
@ -12,17 +13,13 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let tests = [];
|
||||
|
||||
function fuzzeq(a, b, msg) {
|
||||
ok(Math.abs(a - b) < 1e-6, msg);
|
||||
}
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let info = getViewportInfo(800, 480);
|
||||
fuzzeq(info.defaultZoom, 0.1, "initial scale is unspecified");
|
||||
fuzzeq(info.minZoom, 0.1, "minimum scale defaults to the absolute minimum");
|
||||
|
@ -35,29 +32,15 @@
|
|||
info = getViewportInfo(490, 600);
|
||||
is(info.width, 980, "width is still the default width");
|
||||
is(info.height, 1200, "height is proportional to the new displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.width, 980, "width is still the default width");
|
||||
is(info.height, 588, "height is still proportional to displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 1, "initial zoom is 100%");
|
||||
is(info.width, 800, "width is the same as the displayWidth");
|
||||
|
@ -30,30 +27,16 @@
|
|||
info = getViewportInfo(900, 600);
|
||||
is(info.width, 900, "changing the displayWidth changes the width");
|
||||
is(info.height, 600, "changing the displayHeight changes the height");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
let info = getViewportInfo(900, 600);
|
||||
is(info.defaultZoom, 1.5, "initial zoom is 150%");
|
||||
is(info.width, 600, "width equals displayWidth/1.5");
|
||||
is(info.height, 400, "height equals displayHeight/1.5");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 1, "initial zoom is 100%");
|
||||
is(info.width, 800, "width is the same as the displayWidth");
|
||||
|
@ -30,30 +27,16 @@
|
|||
info = getViewportInfo(900, 600);
|
||||
is(info.width, 900, "changing the displayWidth changes the width");
|
||||
is(info.height, 600, "changing the displayHeight changes the height");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
let info = getViewportInfo(900, 600);
|
||||
is(info.defaultZoom, 1.5, "initial zoom is 150%");
|
||||
is(info.width, 600, "width equals displayWidth/1.5");
|
||||
is(info.height, 400, "height equals displayHeight/1.5");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="width=320">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 80);
|
||||
is(info.defaultZoom, 2.5, "initial zoom fits the displayWidth");
|
||||
is(info.width, 320, "width is set explicitly");
|
||||
|
@ -31,31 +28,17 @@
|
|||
is(info.defaultZoom, 1.5, "initial zoom fits the new displayWidth");
|
||||
is(info.width, 320, "explicit width is unchanged");
|
||||
is(info.height, 533, "height changes proportional to displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
// With an explicit width in CSS px, the scaleRatio has no effect.
|
||||
let info = getViewportInfo(800, 80);
|
||||
is(info.defaultZoom, 2.5, "initial zoom still fits the displayWidth");
|
||||
is(info.width, 320, "width is still set explicitly");
|
||||
is(info.height, 40, "height is still minimum height");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 1, "initial zoom is set explicitly");
|
||||
is(info.width, 800, "width fits the initial zoom level");
|
||||
|
@ -31,30 +28,16 @@
|
|||
is(info.defaultZoom, 1, "initial zoom is still set explicitly");
|
||||
is(info.width, 480, "width changes to match the displayWidth");
|
||||
is(info.height, 800, "height changes to match the displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 1.5, "initial zoom is adjusted for device pixel ratio");
|
||||
is(info.width, 533, "width fits the initial zoom");
|
||||
is(info.height, 320, "height fits the initial zoom");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="user-scalable=NO">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,24 +14,10 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
add_task(function test1() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.allowZoom, true, "user-scalable values are case-sensitive; 'NO' is not valid");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="width=2000, minimum-scale=0.75">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.minZoom, 0.75, "minumum scale is set explicitly");
|
||||
is(info.defaultZoom, 0.75, "initial scale is bounded by the minimum scale");
|
||||
|
@ -34,32 +31,18 @@
|
|||
is(info.defaultZoom, 1, "initial scale fits the width");
|
||||
is(info.width, 2000, "width is set explicitly");
|
||||
is(info.height, 1000, "height is proportional to the new displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.5),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.5));
|
||||
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.minZoom, 1.125, "minumum scale is converted to device pixel scale");
|
||||
is(info.defaultZoom, 1.125, "initial scale is bounded by the minimum scale");
|
||||
is(info.maxZoom, 15, "maximum scale defaults to the absolute maximum");
|
||||
is(info.width, 2000, "width is still set explicitly");
|
||||
is(info.height, 1200, "height is still proportional to displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length)
|
||||
(tests.shift())();
|
||||
else
|
||||
SimpleTest.finish();
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<title>meta viewport test</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta name="viewport" content="width=320">
|
||||
<script src="viewport_helpers.js"></script>
|
||||
|
@ -13,13 +14,9 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
add_task(async function test1() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
let tests = [];
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
updateViewport("width=device-width");
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 1, "initial zoom is 100%");
|
||||
|
@ -31,14 +28,11 @@
|
|||
info = getViewportInfo(900, 600);
|
||||
is(info.width, 900, "changing the displayWidth changes the width");
|
||||
is(info.height, 600, "changing the displayHeight changes the height");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test2() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
add_task(async function test2() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
updateViewport("width=320");
|
||||
let info = getViewportInfo(800, 80);
|
||||
is(info.defaultZoom, 2.5, "initial zoom fits the displayWidth");
|
||||
|
@ -51,46 +45,28 @@
|
|||
is(info.defaultZoom, 1.5, "initial zoom fits the new displayWidth");
|
||||
is(info.width, 320, "explicit width is unchanged");
|
||||
is(info.height, 533, "height changes proportional to displayHeight");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test3() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
add_task(async function test3() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
updateViewport("user-scalable=no");
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.allowZoom, false, "zooming is explicitly disabled");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
tests.push(function test4() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
add_task(async function test4() {
|
||||
await SpecialPowers.pushPrefEnv(scaleRatio(1.0));
|
||||
|
||||
updateViewport("user-scalable=yes");
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.allowZoom, true, "zooming is explicitly allowed");
|
||||
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
|
||||
function updateViewport(content) {
|
||||
let meta = document.querySelector("meta[name=viewport]");
|
||||
meta.content = content;
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
if (tests.length) {
|
||||
(tests.shift())();
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
addEventListener("load", nextTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче