Bug 1571650: Add test for AnonymousContent::SetStyle(). r=smaug

In this patch, creates a test to confirm whether the AnonymousContent.setStyle()
works correctly.

Differential Revision: https://phabricator.services.mozilla.com/D41928

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daisuke Akatsuka 2019-08-17 18:47:28 +00:00
Родитель c6a47f400c
Коммит 461170519e
3 изменённых файлов: 37 добавлений и 1 удалений

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

@ -257,6 +257,7 @@ skip-if = fission # Crashes: @ mozilla::dom::ContentParent::RecvDetachBrowsingCo
skip-if = headless # Bug 1405867
[test_anonymousContent_insert.html]
[test_anonymousContent_manipulate_content.html]
[test_anonymousContent_set_style.html]
[test_anonymousContent_style_csp.html]
[test_appname_override.html]
[test_async_setTimeout_stack.html]

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

@ -46,7 +46,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1020244
let members = ["getTextContentForElement", "setTextContentForElement",
"getAttributeForElement", "setAttributeForElement",
"removeAttributeForElement", "getCanvasContext",
"setAnimationForElement"];
"setAnimationForElement", "setStyle"];
for (let member of members) {
ok(member in anonymousContent, "AnonymousContent object defines " + member);
}

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

@ -0,0 +1,35 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1571650
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1571650 - Test AnonymousContent.setStyle() API</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571650">Mozilla Bug 1571650</a>
<script type="application/javascript">
const chromeDocument = SpecialPowers.wrap(document);
info("Set z-index to anonymous content");
const div = document.createElement("div");
div.setAttribute("class", "set-style-test");
const anonymousContent = chromeDocument.insertAnonymousContent(div);
anonymousContent.setStyle("z-index", 3);
info("Test the element which became to anonymous");
const mozCustomContentContainerEl =
[...SpecialPowers.InspectorUtils.getChildrenForNode(document.documentElement, true)]
.find(n => n.classList && n.classList.contains("moz-custom-content-container"));
const targetEl = mozCustomContentContainerEl.querySelector(".set-style-test");
ok(targetEl, "Element which became to anonymous is found");
is(targetEl.style.zIndex, "3", "z-index is correct");
chromeDocument.removeAnonymousContent(anonymousContent);
</script>
</body>
</html>