Commit Graph

93 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
bfcf9b881b Bug 1574544 - Remove now-unnecessary condition that makes the frame constructor get confused with editor anonymous nodes. r=mats
This condition was needed when FindInsertionPrevSibling and co didn't understand
display: contents.

Editor is pretty broken (and calls into PresShell::ContentRemoved directly, and
incorrectly, using anonymous nodes).

In this case we were taking the XBL path because of display: contents, which
means that we tried to seek to the editor anonymous node, and crash (since it's
not an explicit kid).

Editor needs to get fixed, but this is technically more correct and fixes the
crash, so we may as well take it in the interim.

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

--HG--
extra : moz-landing-system : lando
2019-08-19 12:16:28 +00:00
Emilio Cobos Álvarez
7540d08d90 Bug 1556799 - Remove manual NAC as soon as parent chain changes. r=masayuki
Having NAC bound to the tree when not connected is not quite fine, make sure to
clean up properly.

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

--HG--
extra : moz-landing-system : lando
2019-06-06 01:48:10 +00:00
Masayuki Nakano
d9e3ea7e57 Bug 1426709 - Make HTMLEditor update selection ancestor limit synchronously when editing host is changed to ancestor element r=smaug
`HTMLEditor` initializes selection ancestor limit when it receives `focus`
event.  If `Document.execCommand()` is called immediately after an
ancestor of active editing host becomes new editing host,
`HTMLEditor::GetActiveEditingHost()` returns the new one, but selection
ancestor limit is still the previous one.  This mismatch causes a lot of
bugs.  Therefore, this patch makes `nsGenericHTMLElement` notifies `HTMLEditor`
of an element becoming `contenteditable`, and makes `HTMLEditor` update
selection ancestor limit only when the new editing host is ancestor of
old selection ancestor limit.

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

--HG--
extra : moz-landing-system : lando
2019-06-04 08:42:43 +00:00
Masayuki Nakano
761f01d612 Bug 1533913 - Make HTMLEditRules::ApplyBlockStyle() stop handling it if target node is moved from expected container unexpectedly r=m_kato
`HTMLEditRules::ApplyBlockStyle()` stores `curBlock` and `newBlock` during its
loop to keep handling from deeper child to ancestor, and may do two things for
a `curNode`.  If `curBlock` and/or `newBlock` is moved from expected container
when it sets one of or both of them, this patch check whether mutation event
listeners change the DOM tree.  Additionally, this patch also checks whether
`curNode' is moved by mutation event listener at first step of two jobs for it.

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

--HG--
extra : moz-landing-system : lando
2019-05-29 04:44:23 +00:00
Masayuki Nakano
4fe540db19 Bug 1547897 - Make WSRunObject stop scanning outside of editing host r=m_kato
`WSRunObject` scans previous and next node of given point/range **without**
checking editing host boundary.  Therefore, its methods may return non-editable
nodes or editable nodes in another editing host.  In such cases, `HTMLEditRules`
is confused.

This patch makes it store editing host at initialization and it check the
boundary.  However, the former cost may appear in score of some benchmark
tests, but we shouldn't allow attackers to use this entrance.

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

--HG--
extra : moz-landing-system : lando
2019-05-27 12:10:23 +00:00
Masayuki Nakano
c6ffcedbf2 Bug 1534394 - Make WSRunObject::InsertText() set aPointAfterInsertedString by itself when HTMLEditor::InsertTextWithTransaction() returns error r=m_kato
Oddly, `WSRunObject::InsertText()` returns `NS_OK` even when
`HTMLEditor::InsertTextWithTransaction()` returns error.  However,
it fails if insertion point is not editable like `<noscript>` element.
In such case, `aPointAfterInsertedString` isn't modified and its caller,
`HTMLEditRules::WillInsertText()` keep handling inserting remaining text
with non-positioned `EditorDOMPoint`.  Therefore, at the next time,
`WSRunObject` fails to do anything since it requires positioned
`EditorDOMPoint`.

For making uplift safer, this patch makes `WSRunObject::InsertText()` set
`aPointAfterInsertedString` by itself when
`HTMLEditor::InsertTextWithTransaction()` returns error.

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

--HG--
extra : moz-landing-system : lando
2019-05-23 06:06:18 +00:00
Masayuki Nakano
33d3bc7789 Bug 1547898 - part 1: The constructor of EditorDOMPointBase which takes all information should allow non-end point of text node r=m_kato
This is a simple mistake of `MOZ_ASSERTION()` in it. When `mParent` is a node
which can have children, `mChild` should be non-`nullptr` or `mOffset` should
/ be set to the end of `mParent`.  But when `mParent` is not a container, any
`mOffset` value should be allowed.

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

--HG--
extra : moz-landing-system : lando
2019-05-07 07:44:04 +00:00
Masayuki Nakano
0b16be82cb Bug 1525481 - part 2: Make EditorBase::DoSplitNode() return error if split nodes are moved/removed unexpectedly r=m_kato
We should stop handling splitting nodes if mutation event listeners move or
remove the split nodes unexpectedly because the post processors may not be
able to keep handling the nodes.  For example, if a node is moved to outside
of editing host, we shouldn't touch it anymore due to non-editable.

This patch makes `EditorBase::DoSplitNode()` return new error for making
any parent callers stop their job, but note that the following patch makes
any public methods expose the new error as exception for compatibility with
Chrome.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 08:29:38 +00:00
Emilio Cobos Álvarez
f8ecce61ec Bug 1470926 - Null-check mBoundFrame after calling SetSelectionRange on it. r=TYLin
This code was already handling the world going away, but did not handle the case
of just getting unbound, which can happen if some selection listener (e.g.,
AccessibleCaret) flushes layout.

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

--HG--
extra : moz-landing-system : lando
2019-02-21 00:18:15 +00:00
Makoto Kato
1c2f8f57a2 Bug 1441619 - Add crashtest. r=masayuki
Summary:
The latest version of Gecko doesn't crash by this HTML, but I would like to add
this for the future.

Bug #: 1441619

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

--HG--
extra : rebase_source : 5633e508d1c1f405465857a71f7c544fbb3782e8
2018-12-18 15:09:52 +09:00
Andrew Swan
62bcb25a7c Bug 1451503 Move most reftest resources from chrome: to resource: r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D5232

--HG--
extra : rebase_source : 00223dacf6cfdfc4bb8505405844f66c7134e2c0
extra : histedit_source : 2d1f6e353e394520038c05b07bcd08ce06908cf2
2018-09-06 16:01:39 -07:00
Makoto Kato
fef13a2f66 Bug 1464251 - SplitNodeDeepWithTransaction might create orphan node. r=masayuki
SplitStyleAbovePoint calls SplitNodeDeepWithTransaction repeatedly. If
SplitNodeDeepWithTransaction creates orphan node like this test case,
this crash occurs.  So we should check whether node becomes orphan node.

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

--HG--
extra : moz-landing-system : lando
2018-08-09 08:22:50 +00:00
Masayuki Nakano
98a833407e Bug 1467794 - Split TextEditor::DeleteSelectionAsAction() to itself and TextEditor::DeleteSelectionAsSubAction() r=m_kato
TextEditor::DeleteSelectionAsAction() is called even if it's a part of edit
action.  For example, it's called to prepare for inserting text.

For bug 1465702, editor itself and edit rules classes should not call
public DeleteSelectionAsAction() directly.  Therefore, this patch creates
DeleteSelectionAsSubAction() for internal use.

Note that this patch adds NS_ASSERTION() to detect wrong caller.  However,
it cannot distinguish if the call is valid, for example, it's allowed to
call DeleteSelectionAsSelection() even if it's handling an edit action but
the method is called via mutation event listener.  So, we need to allow
some assertions with some tests.  But unfortunately, 1405747.html uses
mutation event listener too many times (about 1,000 times) and the number
of assertion isn't stable.  Therefore, this patch makes the test stop using
the mutation event listener 2nd time since I can reproduce the crash with
ESR 52 at the 2nd time.

MozReview-Commit-ID: 1TWaypmnoCC

--HG--
extra : rebase_source : a6a4fb1cbcaf2ab6f10c5f3e7168a6bc0fcb02ed
2018-06-29 20:16:50 +09:00
Makoto Kato
afbbfcc910 Bug 1405897 - Move assertion before setting resizer attribute. r=masayuki
This assertion was added by review comment of bug 1487945. Since mutation event
handler of this test case hides resizer, this case hits this assertion.

Although 4th parameter of SetAttr can control mutation event, if this event
isn't fired, another test case (layout/base/tests/test_bug558663.html) becomes
failure.

So we should move the assertion before setting resizer attribute.

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

--HG--
extra : moz-landing-system : lando
2018-06-29 04:47:21 +00:00
Makoto Kato
b027fd188e Bug 1423776 - Return error when splitted node might be orphan. r=masayuki
This crash occurs when start container of range for range updater is nullptr
in GetNodesForOperation.

Splitted node by SplitNodeDeepWithTransaction can return orphan node, so we
should return error when splitted node is orphan node.

MozReview-Commit-ID: 3ySdzc9FAzL

--HG--
extra : rebase_source : 3c6f37e81641751d32b8a9777b8362baad301ecb
2018-06-04 16:31:38 +09:00
Makoto Kato
bf208eff66 Bug 1423767 - Splitting node might be orphan. r=masayuki
SplitNodeDeepWithTransaction will split nodes until better point. But
this test case becomes that node is orphan into loop.  So I would like to
add more check whether parent is nothing.

MozReview-Commit-ID: EroSV4uVBVL

--HG--
extra : rebase_source : f594bdf7cd9efac7d10e6e05a8f87dadfc761295
2018-05-16 16:54:20 +09:00
Makoto Kato
91af9cea10 Bug 1424450 - Don't set selection on ClearStyle. r=masayuki
This crash is that HTMLEditor::ClearStyle returns nullptr for aNode even if
successful.

When current start node and offset isn't within ancestor limiter,
HTMLEditor::ClearStyle will return nullptr for split node even if successful.
Because SplitNodeTransation returns error since Selection::Collapse is failed.
Then, SplitNodeDeep in HTMLEditor::SplitStyleAvovePoint returns error.  But
this error is ignored.  So node will becomes null even if successful.

CreateStyleForInsertText will set new selection when there is split node, so
we shouldn't set selection on ClearStyle.

Also, InsertNodeTransation is ignored for error when Collapse is failed, but
SplitNodeTransaction isn't ignored.  We should create a rule when collapse is
failed on transaction.

And at feature, we shouldn't set selection in CreateStyleForInsertText, and
then, it should return new insertion point for InsertText instead of setting
new selection.

MozReview-Commit-ID: BRKWLqTfrvC

--HG--
extra : rebase_source : 2cd025e9d40688f643a843b39512dccc2bb7c4a2
2018-04-18 16:13:24 +09:00
Makoto Kato
d0832ccf7e Bug 1444630 - Don't update dictionary after calling UninitSpellChecker. r=masayuki
When calling UninitSpellChecker during calling UpdateDictionary, this crash
occurs.  Since Thunderbird calls UninitSpellChecker by [Recheck Text] button,
this only occurs on Thunderbird.

After calling UninitSpellChecker, we should not update dictionary.

MozReview-Commit-ID: K4SPJ5FDo8n

--HG--
extra : rebase_source : d760c6472f56cef520c399e8c1f20536c3a22e36
2018-03-20 14:27:06 +09:00
shindli
e83f4555ad Backed out changeset f76b3a9e3005 (bug 1444630) for failures in Z:/task_1521542418/build/tests/reftest/tests/editor/libeditor/crashtests/1444630.html on a CLOSED TREE 2018-03-20 14:03:13 +02:00
Makoto Kato
fda0617389 Bug 1444630 - Don't update dictionary after calling UninitSpellChecker. r=masayuki
When calling UninitSpellChecker during calling UpdateDictionary, this crash
occurs.  Since Thunderbird calls UninitSpellChecker by [Recheck Text] button,
this only occurs on Thunderbird.

After calling UninitSpellChecker, we should not update dictionary.

MozReview-Commit-ID: K4SPJ5FDo8n

--HG--
extra : rebase_source : 67fa439e2a4767502ca84095754150d513a939b2
extra : amend_source : 1b065ebe275cefc02809478eb7d6d807f19dbbee
2018-03-20 14:27:06 +09:00
Makoto Kato
06aaef4673 Bug 1443664 - Form control might not have non-chrome only content. r=smaug 2018-03-20 16:22:39 +09:00
Emilio Cobos Álvarez
06bfed73ea Bug 1446451: GetPropertyValue can indeed not return an integer if the node is not displayed. r=masayuki
MozReview-Commit-ID: Gk0PffVE7bz

--HG--
extra : rebase_source : ded727b58d4184a9723d9f2d196882462384bce7
2018-03-16 18:07:33 +01:00
Makoto Kato
5c5237a5a1 Bug 1402526 - Add crashtest. r=me a=test-only 2018-01-15 14:27:45 +09:00
Makoto Kato
2ca662631f Bug 1425091 - Part 2. Add crashtest. r=masayuki
MozReview-Commit-ID: APqtZUv1q6y

--HG--
extra : rebase_source : 80b64a193a322543c6a34041d77fb5445776e902
2017-12-15 10:51:53 -06:00
Masayuki Nakano
c94238ae4f Bug 1415231 - Add crash tests for a regression of bug 1406482 which has been fixed by bug 1415509 r=m_kato
This crash test can cause crash before landing the patches for bug 1415509.
So, let's take this for regression test.

MozReview-Commit-ID: 652wi49e720

--HG--
extra : rebase_source : a7a897670220e4f14df91c4093e65aa7da7f6015
2017-11-10 10:58:33 +09:00
Makoto Kato
5edeee8f72 Bug 1414581 - Part 2. Add crashtest. r=masayuki
MozReview-Commit-ID: 3H4DSubkt0q

--HG--
extra : rebase_source : e34e609f0056398f799dc6dbdf769cca89a412df
2017-11-06 17:06:09 +09:00
Masayuki Nakano
b327dea259 Bug 1411345 - HTMLEditRules::GetHighestInlineParent() shouldn't return editing host even when it's the highest inline parent of aNode r=m_kato
HTMLEditRules::BustUpInlinesAtRangeEndpoints() tries to split all inline nodes
at range start and range end.  It uses EditorBase::SplitNodeDeep() to split
the nodes and HTMLEditRules::GetHighestInlineParent() to retrieve the highest
inline parent of them.

Currently, HTMLEditRules::GetHighestInlineParent() may return editing host or
ancestor of it if active editing host is not block.  Then, it may cause
splitting editing host or its parents and following methods of HTMLEditRules
will fail to modify the nodes created outside the editing host.

So, HTMLEditRules::GetHighestInlineParent() should return only one of the
descendants of active editing host.

Unfortunately, even if just adding the test case as a crash test, I cannot
reproduce the crash with automated tests.  Therefore, this patch doesn't
include any automated tests.

And this patch changes a crash test, 1402196.html, which expects that an inline
editing host is split by execCommand("insertOrderedList").  However, this patch
fixes this wrong behavior.  Therefore, this patch changes the event target of
event listener from <p> inside the editing host to the editing host itself.

MozReview-Commit-ID: 8i5ci1fcrDd

--HG--
extra : rebase_source : 572a7b22550a38ca71c954f62eefa695addd53c2
2017-10-31 01:14:58 +09:00
Makoto Kato
6190312b6f Bug 1402196 - Part 2. Add crashtest. r=masayuki
MozReview-Commit-ID: IF6UsY3QR1A

--HG--
extra : rebase_source : 9369e9888d436881e5d718666d2c560707f92f57
2017-10-23 12:24:04 +09:00
Jason Kratzer
735da145f2 Bug 1344097 - Add crashtest. r=me
--HG--
extra : rebase_source : 9789bb530c86279907b5abbd8fd1c8e1929e5af1
2017-10-20 08:36:12 -04:00
Ehsan Akhgari
1349bede70 Bug 1408170 - Set child correctly in HTMLEditRules::GetPromotedPoint(); r=masayuki 2017-10-13 02:23:12 -04:00
Jesse Schwartzentruber
beb397098f Bug 1274050 - Add crashtest. r=me 2017-10-12 22:41:14 -04:00
Sebastian Hengst
f7efb5fc2c Merge mozilla-central to mozilla-inbound. r=merge a=merge on a CLOSED TREE 2017-10-12 12:03:15 +02:00
Makoto Kato
4afdbeeecb Bug 1364133 - Part 2. Add test. r=masayuki
MozReview-Commit-ID: 5v1LXlWIRPB

--HG--
extra : rebase_source : b201da76921c032cdf18093d385e7fa48c6bdb4c
2017-10-11 17:59:02 +09:00
Ryan VanderMeulen
6090989771 Bug 1393171 - Add crashtest. r=me
--HG--
extra : rebase_source : 76957b4f171ebf0de582eeffc73330b71425f363
2017-10-11 19:54:10 -04:00
Ryan VanderMeulen
fee107246e Bug 1383763 - Add crashtest. r=me
--HG--
extra : rebase_source : 64f0ebc53170c3b8871f77365829bbdbc5c094eb
2017-10-11 19:54:09 -04:00
Ryan VanderMeulen
2517ed2733 Bug 1384161 - Add crashtest. r=me
--HG--
extra : rebase_source : 2916754a521a451766b1b154c8f80e91dca8ab88
2017-10-11 19:54:09 -04:00
Ryan VanderMeulen
fa5fde2e25 Bug 1383747 - Add crashtest. r=me
--HG--
extra : rebase_source : 82d9e01850c972d5228accacd90cf38e407136c8
2017-10-11 19:54:08 -04:00
Ryan VanderMeulen
9344c09f7c Bug 1388075 - Add crashtest. r=me
--HG--
extra : rebase_source : 70738bf0b3995786e9a472b268d2a0e9745c4160
2017-10-11 11:52:40 -04:00
Makoto Kato
59c8e03ca6 Bug 1402904 - Part 2. Add crash tests. r=masayuki
1405747.html is kind of same issue.  But when editing 1405747.html, the crash doesn't occur.  So I keep original HTML by jsfuzzy.

MozReview-Commit-ID: 9BcUkWeBlr5

--HG--
extra : rebase_source : 1bac60293d3b4997a380cf625c6492db22f60160
extra : histedit_source : eae38e2d69e0705545acf1ef1f2d04e7977b8899
2017-10-05 14:23:12 +09:00
Makoto Kato
24d3058066 Bug 1402469 - Part 2. Add crash test. r=masayuki
MozReview-Commit-ID: HogVH2OTyd6

--HG--
extra : rebase_source : 61e23c7fcc466eccef8bf496436841fe153c4767
2017-09-25 14:11:29 +09:00
Makoto Kato
3ee9303468 Bug 1381541 - queryCommandState should consider that parent node of selection is null. r=masayuki
When parent node of selected node is null, crash might occur in GetCSSBackgroundColorState.  So when parent is null, we should return default value.  In this situation, Edge and Blink don't throw error, Gecko shouldn't return error too.

MozReview-Commit-ID: 5C6jSAFkCso

--HG--
extra : rebase_source : 0185f9fb5fde92eee5611e6bb95e8676c10b135c
2017-08-18 14:48:39 +09:00
Xidorn Quan
179961b3c9 Bug 1383845 - Enable tests disabled for bug 1383845. r=TYLin
MozReview-Commit-ID: Glao9d9PiUF

--HG--
extra : rebase_source : cfc70fcb350a7ee8e325ba1bda0bcdead62d786e
2017-08-17 10:51:59 +10:00
Makoto Kato
3d4f2d6fdc Bug 1383755 - Part 2. Add crash test for object resizer. r=masayuki
MozReview-Commit-ID: WLyLl5vIj0

--HG--
extra : rebase_source : c1166eefe7787761346e6bad069b34dcb42c94e7
2017-07-27 18:21:27 +09:00
J. Ryan Stinnett
c79cb3fbb1 Bug 1380053 - Stylo reftest annotations for all OSes. r=manishearth
MozReview-Commit-ID: JNsNUOZfd2e

--HG--
extra : rebase_source : 05a71f9a0fe484c93931fb230cf0752a3b1b8b00
2017-07-20 22:02:00 -05:00
Yoshi Huang
7036b3761f Bug 1382531 - Part 1: rewrite crashtest for data: URI is unique opaque origin. r=smaug 2017-07-25 09:56:02 +08:00
Yoshi Huang
71b8c7686e Bug 1377492 - fix mochitest-1 failure in docshell when data: URI is a unique origin. r=smaug
When we turn on the pref security.data_uri.unique_opaque_origin to make
data URI is unique origin, the following tests will fail because now
data document is treated as cross origin, so we replace data URIs with
seperate files, hence it will still in the same origin.
2017-07-12 10:35:54 +08:00
Makoto Kato
86506e2303 Bug 1345015 - Part 3. Add crash test. r=masayuki
Add minimal crash test for this.  When removing a line, this doesn't occur.

MozReview-Commit-ID: JqS2E8q47ML

--HG--
extra : rebase_source : 322a77cbc49e29bbd6b705650485634dd4801b8b
2017-06-19 16:52:05 +09:00
Makoto Kato
82d2f60a4d Bug 1375131 - Part 2. Add crash test. r=masayuki
MozReview-Commit-ID: DxYWPNcb7jK

--HG--
extra : rebase_source : f5c5ca6d6fb4c3bb276398b08c81eda1a72b84ae
2017-06-23 16:45:50 +09:00
Makoto Kato
a7f8e06327 Bug 1343918 - Add crash test for document.execCommand('italic'). r=masayuki
Although this crash doesn't occur after landing bug 1369140, we should add this test to crashtest.

MozReview-Commit-ID: mRm4P876zg

--HG--
extra : rebase_source : 9a85c8ba3a5652000512d165b82df9aa2c8176e1
2017-06-20 14:46:28 +09:00
sjh21a
efde6a4d01 Bug 1366176 part 2 - Crashtest.
MozReview-Commit-ID: 3HJBIv97vk6
2017-05-23 19:09:26 +02:00