Bug 1421568 - Add a ChromeOnly method to access also closed shadow roots, r=mrbkap

--HG--
extra : rebase_source : 4c596aa8938c2c325a9f6f4448050df5f8f6c9a0
This commit is contained in:
Olli Pettay 2018-02-03 12:15:25 +02:00
Родитель 7be5dd985e
Коммит b0ee39f2c7
3 изменённых файлов: 58 добавлений и 0 удалений

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

@ -614,6 +614,7 @@ skip-if = toolkit == 'android'
[test_bug1399605.html]
[test_bug1404385.html]
[test_bug1406102.html]
[test_bug1421568.html]
[test_caretPositionFromPoint.html]
[test_change_policy.html]
[test_clearTimeoutIntervalNoArg.html]

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

@ -0,0 +1,53 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1421568
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1421568</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript"><!--
/** Test for Bug 1421568 **/
SimpleTest.waitForExplicitFinish();
function init() {
SpecialPowers.pushPrefEnv({
set: [["dom.webcomponents.shadowdom.enabled", true]]
},
function () {
document.getElementById("content").innerHTML =
"<iframe src='about:blank' onload='test(this)'></iframe>";
});
}
function test(iframe) {
var d = iframe.contentDocument;
d.body.innerHTML = "<div>";
var div = d.body.firstChild;
var sr = div.attachShadow({mode: "closed"});
is(sr.mode, "closed", "Shadow root should be closed.");
is(div.shadowRoot, null, "Closed shadow root shouldn't be exposed.");
is(div.openOrClosedShadowRoot, undefined,
"openOrClosedShadowRoot should be exposed to the privileged scripts only.");
ok("openOrClosedShadowRoot" in SpecialPowers.wrap(div),
"Should have openOrClosedShadowRoot in privileged wrapper.")
is(SpecialPowers.unwrap(SpecialPowers.wrap(div).openOrClosedShadowRoot), sr);
SimpleTest.finish();
}
//--></script>
</head>
<body onload="init()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1421568">Mozilla Bug 1421568</a>
<p id="display"></p>
<div id="content">
</div>
<pre id="test">
</pre>
</body>
</html>

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

@ -268,6 +268,10 @@ partial interface Element {
ShadowRoot attachShadow(ShadowRootInit shadowRootInitDict);
[BinaryName="shadowRootByMode", Func="nsDocument::IsShadowDOMEnabled"]
readonly attribute ShadowRoot? shadowRoot;
[ChromeOnly, Func="nsDocument::IsShadowDOMEnabled", BinaryName="shadowRoot"]
readonly attribute ShadowRoot? openOrClosedShadowRoot;
[BinaryName="assignedSlotByMode", Func="nsDocument::IsShadowDOMEnabled"]
readonly attribute HTMLSlotElement? assignedSlot;
[CEReactions, Unscopable, SetterThrows, Func="nsDocument::IsShadowDOMEnabled"]