Sha256: 260e78c225178c2dd0792e6b5494cc285fb6b934d3efc44ac2789eac32060c91

Contents?: true

Size: 1.82 KB

Versions: 8

Compression:

Stored size: 1.82 KB

Contents

<!DOCTYPE html>
<!--

  @author marcosalmeida@google.com (Marcos Almeida)
-->
<html>
<!--
Copyright 2009 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.editor.focus</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.dom.selection');
  goog.require('goog.editor.focus');
  goog.require('goog.editor.BrowserFeature');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>

  <div>
    <input type="text" id="myInput" value="my value">
    <a href="" id="dummyLink">dummy</a>
  </div>

<script>

  function setUp() {
    // Make sure focus is not in the input to begin with.
    var dummy = document.getElementById('dummyLink');
    dummy.focus();
  }


  /**
   * Tests that focusInputField() puts focus in the input field and sets the
   * cursor to the end of the text cointained inside.
   */
  function testFocusInputField() {
    var input = document.getElementById('myInput');
    assertNotEquals('Input should not be focused initially',
                    input,
                    document.activeElement);

    goog.editor.focus.focusInputField(input);
    if (goog.editor.BrowserFeature.HAS_ACTIVE_ELEMENT) {
      assertEquals('Input should be focused after call to focusInputField',
                   input,
                   document.activeElement);
    }
    assertEquals('Selection should start at the end of the input text',
                 input.value.length,
                 goog.dom.selection.getStart(input));
    assertEquals('Selection should end at the end of the input text',
                 input.value.length,
                 goog.dom.selection.getEnd(input));
  }

</script>
</body>
</html>

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
k4compiler-0.0.1 third_party/closure-library/closure/goog/editor/focus_test.html
middleman-wizard-template-1.0.4 lib/middleman-wizard-template/template/closure/library/closure/goog/editor/focus_test.html
middleman-wizard-template-1.0.3 lib/middleman-wizard-template/template/closure/library/closure/goog/editor/focus_test.html
middleman-wizard-template-1.0.2 lib/middleman-wizard-template/template/closure/library/closure/goog/editor/focus_test.html
middleman-wizard-template-1.0.1 lib/middleman-wizard-template/template/closure/library/closure/goog/editor/focus_test.html
middleman-wizard-template-1.0.0.pre.1 lib/middleman-wizard-template/template/closure/library/closure/goog/editor/focus_test.html
closure-1.2.701 closure-library/closure/goog/editor/focus_test.html
closure-1.1.692 closure-library/closure/goog/editor/focus_test.html