Browser Based Editor Library Test Harness

From W3C Wiki

This is part of a project on an open source Browser_Based_Editing_Library.

The aim is to achieve consistency with word processors like Microsoft Word for basic keystrokes like cursor navigation, enter, backspace and delete. The complexity of the required behavior motivated the development of a test harness and test suite. See:

This has been found to work with Firefox, Chromium, Safari and Internet Explorer 9.

A text format is used for tests, which each test represented with 3 lines. The first line defines the action to be performed, the second the markup before the action, and the third, the markup expected after the action has been applied. The editing caret position is denoted by the vertical bar "|". Tests are separated by a single blank line.

The first line is a comma separated list of actions. Each action can be preceded by any combination of control, shift and alt. Text input is denoted by a "string". This must not include commas, newlines or double quote marks. The other actions include:

  • canonicalise
  • forward
  • backward
  • enter
  • backspace
  • delete

To simplify the code, the library canonicalises markup when loading documents. This involves inserting BR elements in lines that are otherwise collapsed, removing redundant BR elements where these have no effect on the rendering, merging adjacent text nodes, and normalization of whitespace.

Here are a few examples:

enter
<ul><li>|<br></li></ul>
<p>|<br></p>

shift enter
<p><em>ab|</em></p>
<p><em>ab<br>|<br></em></p>

forward
<p>abc|</p><p><em><br></em></p>
<p>abc</p><p><em>|<br></em></p>

backspace
<p><em>abc<br></em>|xyz</p>
<p><em>abc|</em>xyz</p>

enter, "xyz"
<ul><li>abc|</li><li>prq</li></ul>
<ul><li>abc</li><li>xyz|</li><li>prq</li></ul>