Bug 1055977 part 2: Add mochitest to verify that ancestors of a fullscreen element are fixed at the initial values of any properties that can create stacking contexts. r=cpearce

--HG--
rename : content/html/content/test/file_fullscreen-hidden.html => content/html/content/test/file_fullscreen-ancestor-stacking-context.html
This commit is contained in:
Daniel Holbert 2014-08-24 22:11:17 -07:00
Родитель acf9313ae5
Коммит 52d061077a
3 изменённых файлов: 141 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,139 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1056203
-->
<head>
<title>Test for Bug 1056203</title>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1056203">Mozilla Bug 1056203</a>
<p id="display">
<div id="grandparent">
<div id="parent">
<div id="fullscreenElem">
<div id="child"></div>
</div>
</div>
</div>
</p>
<pre id="test">
<script type="application/javascript;version=1.7">
/** Test for Bug 1056203 **/
/* This test ensures that the ancestors of a full-screened element cannot be
restyled to create a stacking context, even with !important. */
/* NOTE: The following hash should include each of the properties from
layout/style/full-screen-override.css (except that this list uses the DOM
versions of the property names -- e.g. "zIndex" instead of "z-index").
Both lists should include every property that is able to induce an element
to form a stacking context. */
const gPropertyTestDecls = {
//"domPropName": "prop-name: some-non-initial-value",
"zIndex": "z-index: 5",
"opacity": "opacity: 0.8",
"mask": "mask: url(#mymask)",
"clip": "clip: rect(0 0 0 0)",
"filter": "filter: url(#myfilter)",
"transform": "transform: translate(0)",
// XXXdholbert The "will-change" line in full-screen-override.css is only
// parsed and honored if "layout.css.will-change.enabled" is turned on
// *at startup time* (so, flipping it here with SpecialPowers wouldn't be
// sufficient). So, we won't get the right behavior for 'will-change' here
// until it's enabled by default (bug 961871). This line can be uncommented
// when that happens:
// "willChange": "will-change: transform"
};
// populated in populateInitialVals
let gPropertyInitialVals = {};
function begin() {
populateInitialVals();
// FIRST: Assert that the properties in gPropertyTestDecls can be set
// on each of our tested elements, before we enter full-screen mode.
var timeDescrip = "not yet fullscreen";
testPropertiesOnElem("grandparent", true);
testPropertiesOnElem("parent", true);
testPropertiesOnElem("fullscreenElem", true);
testPropertiesOnElem("child", true);
document.addEventListener("mozfullscreenchange", handleFullscreen, false);
fullscreenElem.mozRequestFullScreen();
}
function handleFullscreen(e) {
opener.ok(document.mozFullScreen, "should've entered full-screen mode");
// SECOND: Assert that the properties in gPropertyTestDecls can *NOT* be
// set (their decls have no effect) on ancestors of the full-screen elem.
testPropertiesOnElem("parent", false);
testPropertiesOnElem("grandparent", false);
testPropertiesOnElem("fullscreenElem", true);
testPropertiesOnElem("child", true);
// Un-register listener, so we aren't re-triggered when document is torn
// down & taken out of full-screen mode:
document.removeEventListener("mozfullscreenchange", handleFullscreen);
// We're done! On to the next test:
opener.nextTest();
};
// Populates gPropertyTestDecls with the initial values of each property
// in gPropertyTestDecls (based on document.documentElement's computed style)
function populateInitialVals() {
// We'll read the initial values off of document.documentElement.
let cs = window.getComputedStyle(document.documentElement, "");
for (propName in gPropertyTestDecls) {
opener.ok(propName in cs,
"property '" + propName + "' used in this test should " +
"exist in computed style");
gPropertyInitialVals[propName] = cs[propName];
}
}
// For the element with id |elemId|, this method asserts that the property
// decls in gPropertyTestDecls either *do* or *do not* have an effect on the
// element's computed style, depending on the argument |isPropertyModifyable|.
// The decls are tested both with & without "!important".
function testPropertiesOnElem(elemId, isPropertyModifyable) {
const elem = document.getElementById(elemId);
opener.ok(elem, "expecting to find element with ID '" + elemId + "'");
const testFunc = isPropertyModifyable ? opener.isnot : opener.is;
for (propName in gPropertyTestDecls) {
let msg = elemId + ".style." + propName +" should ";
if (!isPropertyModifyable) {
msg += "NOT ";
}
msg += "be allowed to change away from initial value, ";
msg += document.mozFullScreen ? "after" : "before";
msg += " entering full-screen mode";
let decl = gPropertyTestDecls[propName];
// See if the test decl has any effect on computed style:
elem.setAttribute("style", decl);
testFunc(window.getComputedStyle(elem, "")[propName],
gPropertyInitialVals[propName],
msg);
// See if the test decl has any effect on computed style, w/ "!important":
elem.setAttribute("style", decl + " !important");
testFunc(window.getComputedStyle(elem, "")[propName],
gPropertyInitialVals[propName],
msg + " (with !important)");
elem.removeAttribute("style"); // clean up
}
}
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -26,6 +26,7 @@ support-files =
file_bug893537.html
file_formSubmission_img.jpg
file_formSubmission_text.txt
file_fullscreen-ancestor-stacking-context.html
file_fullscreen-api-keys.html
file_fullscreen-api.html
file_fullscreen-denied-inner.html

Просмотреть файл

@ -34,6 +34,7 @@ SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
// run in an iframe, which by default will not have the allowfullscreen
// attribute set, so full-screen won't work.
var gTestWindows = [
"file_fullscreen-ancestor-stacking-context.html",
"file_fullscreen-multiple.html",
"file_fullscreen-rollback.html",
"file_fullscreen-esc-exit.html",