Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: LayoutTests/editing/surrounding-text/surrounding-text.html

Issue 307353002: Use Position instead of VisiblePosition for SurroundingText. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: convert layouttests to unit tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/editing/surrounding-text/surrounding-text.html
diff --git a/LayoutTests/editing/surrounding-text/surrounding-text.html b/LayoutTests/editing/surrounding-text/surrounding-text.html
deleted file mode 100644
index e2dfef78f831396bec99f817acd6ab25cffaf3d7..0000000000000000000000000000000000000000
--- a/LayoutTests/editing/surrounding-text/surrounding-text.html
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<script src="../../resources/js-test.js"></script>
-<div id="test">
-</div>
-<p id="description"></p>
-<div id="console"></div>
-<script>
-description('Test the extraction of the text surrounding an element.');
-
-function findOffsetCoordinates(node, offset) {
- var nodeRange = document.createRange();
- nodeRange.selectNode(node);
-
- var offsetRange = document.createRange();
- offsetRange.setStart(node, offset);
- offsetRange.setEnd(node, offset + 1);
-
- var nodeRect = nodeRange.getBoundingClientRect();
- var offsetRect = offsetRange.getBoundingClientRect();
- var x = (offsetRect.left + offsetRect.right) / 2 - nodeRect.left;
- var y = (offsetRect.top + offsetRect.bottom) / 2 - nodeRect.top;
-
- return { x: x, y: y };
-}
-
-function surroundingText(html, offset, maxLength) {
- document.getElementById('test').innerHTML = html;
-
- var here = document.getElementById('here');
- if (here == null)
- throw 'Test case needs an element with id "here"';
-
- var node = here.hasChildNodes() ? here.firstChild : here.nextSibling;
- if (node == null)
- throw 'No node after "here" element';
-
- var coords = findOffsetCoordinates(node, offset);
- var text = window.internals.textSurroundingNode(node, coords.x, coords.y, maxLength);
- return text.replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
-}
-
-function run() {
- if (!window.internals)
- return;
-
- shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 0, 100)', '12345 6789 12345 6789');
- shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 5, 6)', '89 123');
- shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 5, 0)', '');
- shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 5, 1)', '1');
- shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 6, 2)', '12');
- shouldBeEqualToString('surroundingText(\'<select>.</select><div>57th Street and Lake Shore Drive</div> <span>Chicago</span> <span id="here">IL</span> <span>60637</span><select>.</select>\', 0, 100)', '57th Street and Lake Shore Drive Chicago IL 60637');
- shouldBeEqualToString('surroundingText(\'<fieldset>.</fieldset>12345<button>abc</button><p>6789<br id="here"/>12345</p>6789<textarea>abc</textarea>0123<fieldset>.</fieldset>\', 0, 100)', '6789 12345 6789');
- shouldBeEqualToString('surroundingText(\'<button>.</button><div id="here">This is <!-- comment --!>a test <\' + \'script language="javascript"><\' + \'/script>example<button>.</button>\', 0, 100)', 'This is a test example');
- shouldBeEqualToString('surroundingText(\'<button>.</button><div id="here">012345678901234567890123456789</div><button>.</button>\', 15, 12)', '901234567890');
- shouldBeEqualToString('surroundingText(\'<option>.</option>12345<button id="here">test</button><option>.</option>\', 0, 100)', '');
- shouldBeEqualToString('surroundingText(\'<option>.</option>12345<button>te<span id="here">st</span></button><option>.</option>\', 0, 100)', '');
- shouldBeEqualToString('surroundingText(\'<p id="here">.</p>\', 0, 2)', '.');
-
- document.body.removeChild(document.getElementById('test'));
- finishJSTest();
-}
-
-window.onload = run;
-window.jsTestIsAsync = true;
-window.successfullyParsed = true;
-</script>
-</body>
-</html>
« no previous file with comments | « no previous file | LayoutTests/editing/surrounding-text/surrounding-text-expected.txt » ('j') | Source/web/WebSurroundingText.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698