Revision 61d3da36e6cb16e4d4b9375518b0ae00308ee92a authored by Nicolas Pena on 25 April 2018, 18:35:25 UTC, committed by Blink WPT Bot on 25 April 2018, 18:53:19 UTC
This CL changes the webtiming-resolution to test that resolution is
larger than 10 microseconds, instead of testing for a specific value.
This allows the test to no longer be flaky and to be moved to wpt.

The webtiming-ssl test is moved to WPT, using an https connection to
ensure that secureConnectionStart is correctly defined.

Bug: chromium:801341
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I4d31faa08d00251098f3dc648c794d80bbcc2f22
Reviewed-on: https://chromium-review.googlesource.com/867310
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Robert Ma <robertma@chromium.org>
Reviewed-by: Timothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553666}
1 parent 3a0a2e4
Raw File
dir-manual.html
<!doctype html>
<title>Selection direction tests</title>
<meta charset=utf-8>
<div id=test>
    <p>This is a manual test, since there's no way to synthesize keyboard or
    mouse input.  Click after the letter "c" in the following paragraph and
    drag backwards so that both the "b" and the "c" are highlighted, then click
    the "Test" button:

    <p>abcd <button onclick=testDirection()>Test</button>

    <p>efghi
</div>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done: true});

function testDirection() {
    var testDiv = document.getElementById("test");
    var p = testDiv.getElementsByTagName("p")[1].firstChild;
    var selection = getSelection();
    var range = selection.getRangeAt(0);
    test(function() {
        assert_equals(range.toString(), "bc");
    }, "The expected range is selected");
    test(function() {
        assert_equals(selection.anchorNode, p);
        assert_equals(selection.focusNode, p);
    }, "Expected node is initially selected");
    test(function() {
        assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [1, 3]);
    }, "Expected offsets are initially selected (maybe not in order)");
    test(function() {
        assert_equals(selection.anchorOffset, 3);
        assert_equals(selection.focusOffset, 1);
    }, "Offsets are backwards for initial selection"),
    test(function() {
        assert_equals(selection.anchorNode, range.endContainer);
        assert_equals(selection.anchorOffset, range.endOffset);
        assert_equals(selection.focusNode, range.startContainer);
        assert_equals(selection.focusOffset, range.startOffset);
    }, "Offsets match the range for initial selection");

    // Per spec, the direction of the selection remains even if you zap a range
    // and add a new one.
    test(function() {
        selection.removeRange(range);
        range = document.createRange();
        p = testDiv.getElementsByTagName("p")[0].firstChild;
        range.setStart(p, 0);
        range.setEnd(p, 4);
        assert_equals(range.toString(), "This");
        selection.addRange(range);
    }, "removeRange()/addRange() successful");
    test(function() {
        assert_equals(selection.anchorNode, p);
        assert_equals(selection.focusNode, p);
    }, "Expected node is selected after remove/addRange()");
    test(function() {
        assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [0, 4]);
    }, "Expected offsets are selected after remove/addRange() (maybe not in order)");
    test(function() {
        assert_equals(selection.anchorOffset, 4);
        assert_equals(selection.focusOffset, 0);
    }, "Offsets are backwards after remove/addRange()"),
    test(function() {
        assert_equals(selection.anchorNode, range.endContainer);
        assert_equals(selection.anchorOffset, range.endOffset);
        assert_equals(selection.focusNode, range.startContainer);
        assert_equals(selection.focusOffset, range.startOffset);
    }, "Offsets match the range after remove/addRange()");

    // But if you call removeAllRanges(), the direction should reset to
    // forwards.
    test(function() {
        selection.removeAllRanges();
        range = document.createRange();
        p = testDiv.getElementsByTagName("p")[2].firstChild;
        range.setStart(p, 2);
        range.setEnd(p, 5);
        assert_equals(range.toString(), "ghi");
        selection.addRange(range);
    }, "removeAllRanges() successful");
    test(function() {
        assert_equals(selection.anchorNode, p);
        assert_equals(selection.focusNode, p);
    }, "Expected node is selected after removeAllRanges()");
    test(function() {
        assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [2, 5]);
    }, "Expected offsets are selected after removeAllRanges() (maybe not in order)");
    test(function() {
        assert_equals(selection.anchorOffset, 2);
        assert_equals(selection.focusOffset, 5);
    }, "Offsets are forwards after removeAllRanges()");
    test(function() {
        assert_equals(selection.anchorNode, range.startContainer);
        assert_equals(selection.anchorOffset, range.startOffset);
        assert_equals(selection.focusNode, range.endContainer);
        assert_equals(selection.focusOffset, range.endOffset);
    }, "Offsets match the range after removeAllRanges()");

    done();
}
</script>
back to top