Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.Document


  /**
   * Tests that {@link DOM#isOrHasChild(Element, Element)} works consistently
   * across browsers.
   */
  public void testIsOrHasChild() {
    Document doc = Document.get();
    Element div = DOM.createDiv();
    Element childDiv = DOM.createDiv();
    Text text = Document.get().createTextNode("text");

    // unattached, not related
    assertFalse(div.isOrHasChild(childDiv));
    assertFalse(div.isOrHasChild(text));
    assertTrue(div.isOrHasChild(div));
    assertTrue(text.isOrHasChild(text));
    assertFalse(doc.isOrHasChild(div));
    assertFalse(doc.isOrHasChild(text));
    assertFalse(div.isOrHasChild(doc));
    assertFalse(text.isOrHasChild(doc));

    // unattached, related
    div.appendChild(childDiv);
    childDiv.appendChild(text);
    assertTrue(div.isOrHasChild(childDiv));
    assertTrue(childDiv.isOrHasChild(text));
    assertFalse(childDiv.isOrHasChild(div));
    assertFalse(text.isOrHasChild(childDiv));
    assertFalse(doc.isOrHasChild(div));
    assertFalse(doc.isOrHasChild(text));
    assertFalse(div.isOrHasChild(doc));
    assertFalse(text.isOrHasChild(doc));

    // attached, related
    DOM.appendChild(RootPanel.getBodyElement(), div);
    assertTrue(div.isOrHasChild(childDiv));
    assertTrue(childDiv.isOrHasChild(text));
    assertTrue(div.isOrHasChild(div));
    assertTrue(text.isOrHasChild(text));
    assertFalse(childDiv.isOrHasChild(div));
    assertFalse(text.isOrHasChild(childDiv));
    assertTrue(doc.isOrHasChild(div));
    assertTrue(doc.isOrHasChild(text));
    assertFalse(div.isOrHasChild(Document.get()));
    assertFalse(text.isOrHasChild(Document.get()));
  }
View Full Code Here


    // Now check visible length.
    assertEquals(5, b.getVisibleLength());
  }

  public void testNoNukeTabIndex() {
    Document doc = Document.get();
    DivElement div = doc.createDivElement();
    div.setInnerHTML("<input type='text' id='tb' tabindex='1'></input>");
    doc.getBody().appendChild(div);

    TextBox tb = TextBox.wrap(doc.getElementById("tb"));
    assertEquals(1, tb.getTabIndex());
  }
View Full Code Here

    assertNotNull(widget);
    assertTrue(widget.isAttached());
  }

  private Element ensureDiv() {
    Document doc = Document.get();
    Element div = doc.getElementById("wrapperDiv");
    if (div == null) {
      div = doc.createDivElement();
      div.setId("wrapperDiv");
      doc.getBody().appendChild(div);
    }
    return div;
  }
View Full Code Here

   * Tests that the channel property closes when the underlying window unloads.
   */
  public void testWindowUnloadClosesChannel() {
    final String channelName = "testWindowUnloadClosesChannel";

    final Document document = Document.get();
    final IFrameElement frame = createBlankFrame(document);
    document.getBody().appendChild(frame);

    final WindowExt window = getContentWindow(frame).cast();

    final TestServerListener serverListener = new TestServerListener();
    Server.listen(window, channelName, serverListener);

    final TestListener clientListener = new TestListener();
    Client.connect(window, channelName, clientListener);

    ServerClientAndListener serverPair = serverListener.getListenerAndChannelAt(0);
    assertTrue("Channel is null.", serverPair.channel != null);
    assertTrue("Listener is null.", serverPair.listener != null);

    assertTrue("server failed to connect.", serverPair.listener.isConnected());
    assertTrue("client failed to connect.", clientListener.isConnected());

    document.getBody().removeChild(frame);

    assertFalse("server failed to auto-close.",
        serverPair.listener.isConnected());
    assertFalse("client failed to auto-close.", clientListener.isConnected());
  }
View Full Code Here

  private Transition doMakeTimelineData() {
    Timer t = new Timer() {
      int count = 0;

      public void run() {
        Document doc = Document.get();
        DivElement div = doc.createDivElement();
        div.setInnerHTML("<b>(dyanmically added div)</b>");
        div.getStyle().setBorderStyle(BorderStyle.SOLID);
        div.getStyle().setBorderColor("#b33");
        div.getStyle().setBorderWidth(1.0, Unit.PX);
        doc.getBody().appendChild(div);
        if (count++ > 6) {
          runStateMachine(Transition.ACTION_COMPLETE);
        } else {
          this.schedule(250);
        }
View Full Code Here

  /**
   * Invoked at the end of a successful test, this method reports success to
   * JUnit and cleans up the state machine for the next run.
   */
  private Transition doTestSuccessful() {
    Document doc = Document.get();
    DivElement statusDiv = doc.createDivElement();
    statusDiv.setInnerText("called finishTest()");
    doc.getBody().appendChild(statusDiv);
    finishTest();
    currentState = State.IDLE;
    return Transition.TERMINATE;
  }
View Full Code Here

  public void testIFrameManipulation() {
    $(e).html("<iframe name='miframe' id='miframe' src=\"javascript:''\">");
    // FF has to call empty to open and close the document before
    // accessing the recently created iframe content
    Document d = $("#miframe").contents().empty().get(0).cast();
    assertNotNull(d);
    assertNotNull(d.getBody());
    assertEquals(1, $("#miframe").contents().size());
    assertEquals(1, $("#miframe").contents().find("body").size());
    assertEquals(0, $("#miframe").contents().find("body > h1").size());
    $("#miframe").contents().find("body").append("<h1>Test</h1>");
    assertEquals(1, $("#miframe").contents().find("body > h1").size());
View Full Code Here

      Node ctx) /*-{
      return ctx.getElementsByClassName(selector);
  }-*/;

  public static NodeList<Element> veryQuickId(String id, Node ctx) {
    Document d = ctx.getNodeType() == Node.DOCUMENT_NODE
        ? ctx.<Document> cast() : ctx.getOwnerDocument();
    return JsNodeArray.create(d.getElementById(id));
  }
View Full Code Here

        src = "https://ssl.google-analytics.com/ga.js";
      } else {
        src = "http://www.google-analytics.com/ga.js";
      }

      Document doc = Document.get();
      ScriptElement script = doc.createScriptElement();
      script.setSrc(src);
      script.setType("text/javascript");
      doc.getBody().appendChild(script);

      return false;
    }
View Full Code Here

   *          The tick for which you want to obtain a stock box.
   * @return The div within the current document that contains all the information about the given tick's stock. It will
   *         have been freshly cloned from the prototype if necessary.
   */
  private DivElement getStockBoxDiv(Tick tick) {
    Document document = RootPanel.getBodyElement().getOwnerDocument();

    // find our stock box, creating if necessary
    DivElement stockBoxDiv = (DivElement) document.getElementById("stockbox." + tick.getSymbol());
    if (stockBoxDiv == null) {
      DivElement prototype = (DivElement) document.getElementById("prototypeStockBox");
      stockBoxDiv = (DivElement) prototype.cloneNode(true);
      stockBoxDiv.setId("stockbox." + tick.getSymbol());
      RootPanel.getBodyElement().appendChild(stockBoxDiv);
    }
    return stockBoxDiv;
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.