New issue
Advanced search Search tips

Issue 910130 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task



Sign in to add a comment

snav-testharness.js can't evaluate focused iframe.

Project Member Reported by junho092...@lge.com, Nov 29

Issue description


Let's say we are testing following case:
<!doctype html>
<iframe id="start" tabindex="0" style="display:inline-block; width: 100px; height: 35px" src="data:text/html,
    <br><br><br>
    <p>Text</p>
  ">
</iframe>

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
  var resultMap = [
    ["Down", "start"],
  ];

  document.getElementById("start").focus();
  snav.assertFocusMoves(resultMap);
</script>



And let's see stepAndAssertMoves():
  function stepAndAssertMoves(expectedMoves) {
    if (expectedMoves.length == 0) {
      if (gPostAssertsFunc)
        gPostAssertsFunc();
      gAsyncTest.done();
      return;
    }

    let move = expectedMoves.shift();
    let direction = move[0];
    let expectedId = move[1];
    let wanted = findElement(expectedId);
    let receivingDoc = wanted.ownerDocument;
    let verifyAndAdvance = gAsyncTest.step_func(function() {
      let focused = focusedDocument().activeElement;
      assert_equals(focused, wanted);
      // Kick off another async test step.
      stepAndAssertMoves(expectedMoves);
    });

    // "... the default action MUST be to shift the document focus".
    //   https://www.w3.org/TR/uievents/#event-type-keydown
    // Any focus movement must have happened during keydown, so once we got
    // the succeeding keyup-event, it's safe to assert activeElement.
    // The keyup-event targets the, perhaps newly, focused document.
    receivingDoc.addEventListener('keyup', verifyAndAdvance, {once: true});
    triggerMove(direction);
  }


Problem 1.
Result element from findElement(expectedId): iframe element.
focusedDocument().activeElement: body element inside iframe's document.

Problem 2.
Event target document for 'keyup' event: iframe's document.
Document what we are adding event listener: iframe's owner document(parent document).

Problem 1 introduces assert equal.
Problem 2 introduces timeout.
 
Components: Blink>HTML>Focus
Labels: -Type-Bug Type-Task
Status: Available (was: Untriaged)
Description: Show this description

Sign in to add a comment