-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1891783 - Fix two more bugs in ShadowDOM Selection r=jjaschke,sma…
…ug,dom-core Bug #1: AbstractRange::(Mark|Unmark)Descendants should always use the shadow tree of web-exposed shadow root, instead of using light DOM elements of the host. Bug #2: aRange could possibly create mCrossShadowBoundaryRange first (due to boundaries are in different tree), and later moves the boundaries to the same tree. When this happens, we should remove mCrossShadowBoundaryRange and use the default range to represent it. Differential Revision: https://phabricator.services.mozilla.com/D207608
- Loading branch information
Showing
7 changed files
with
243 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
layout/generic/test/test_selection_cross_shadow_boundary_backward_nested_click.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE HTML> | ||
<script src="/tests/SimpleTest/EventUtils.js"></script> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> | ||
<script> | ||
SimpleTest.waitForExplicitFinish(); | ||
function run() { | ||
const host = document.getElementById("host"); | ||
const inner = host.shadowRoot.getElementById("inner"); | ||
const innerRect = inner.getBoundingClientRect(); | ||
|
||
const innerHost = host.shadowRoot.getElementById("innerHost"); | ||
const nested = innerHost.shadowRoot.getElementById("nested"); | ||
const nestedRect = nested.getBoundingClientRect(); | ||
|
||
// Click the center of "NestedText" | ||
synthesizeMouse(nested, nestedRect.width / 2, nestedRect.height / 2, { type: "mousedown" }); | ||
synthesizeMouse(nested, nestedRect.width / 2, nestedRect.height / 2, { type: "mouseup" }); | ||
|
||
// Click the center of "InnerText" | ||
synthesizeMouse(inner, innerRect.width / 2, innerRect.height / 2, { type: "mousedown", shiftKey: true}); | ||
synthesizeMouse(inner, innerRect.width / 2, innerRect.height / 2, { type: "mouseup" , shiftKey: true}); | ||
|
||
// Above two clicks should select half of the content in "InnerText" and half of the content in "NestedText" | ||
let sel = document.getSelection().getComposedRanges(host.shadowRoot, innerHost.shadowRoot)[0]; | ||
|
||
// forward selection | ||
is(sel.startContainer, inner.firstChild, "startContainer is the InnerText"); | ||
is(sel.endContainer, nested.firstChild, "endContainer is the NestedText"); | ||
|
||
const collapsedRange = document.getSelection().getRangeAt(0); | ||
is(collapsedRange.startContainer, inner.firstChild, "normal range's startContainer get collapsed to InnerText"); | ||
is(collapsedRange.endContainer, inner.firstChild, "normal range's endContainer get collapsed to InnerText"); | ||
|
||
SimpleTest.finish(); | ||
} | ||
</script> | ||
<body onload="SimpleTest.waitForFocus(run);"> | ||
<div id="host"> | ||
<template shadowrootmode="open"> | ||
<span id="inner">InnerText</span> | ||
<div id="innerHost"> | ||
<template shadowrootmode="open"> | ||
<span id="nested">NestedText</span> | ||
</template> | ||
</div> | ||
</template> | ||
</div> | ||
</body> |
Oops, something went wrong.