@Override protected void onFrameLoaded() { Document doc = getDocument(); PreElement pre = doc.createPreElement(); pre.setInnerText(code_); pre.getStyle().setProperty("whiteSpace", "pre-wrap"); pre.getStyle().setFontSize(fontSize_, Unit.PT); doc.getBody().appendChild(pre); getWindow().print(); // Bug 1224: ace: print from source causes inability to reconnect // This was caused by the iframe being removed from the document too // quickly after the print job was sent. As a result, attempting to // navigate away from the page at any point afterwards would result // in the error "Document cannot change while printing or in Print // Preview". The only thing you could do is close the browser tab. // By inserting a 5-minute delay hopefully Firefox would be done with // whatever print related operations are important. Scheduler.get() .scheduleFixedDelay( new RepeatingCommand() { public boolean execute() { PrintIFrame.this.removeFromParent(); return false; } }, 1000 * 60 * 5); }
@Test public void checkGetElementByIdInBody() { // Setup AnchorElement a = Document.get().createAnchorElement(); a.setId("myId"); DivElement div = Document.get().createDivElement(); div.appendChild(a); d.getBody().appendChild(div); // Test Element result = d.getElementById("myId"); // Assert Assert.assertEquals(a, result); }
/** * Creates a new client channel. * * @param document the document in which to insert the iframe * @param url the url to the remote peer * @param listener a callback to be notified on channel events */ public Client(Document document, String url, final ClientListener listener) { origin = getDomain(url); frame = document.getBody().appendChild(createFrame(document, url)); receiver = new Responder(getCurrentWindow(), origin, listener); remover = Event.addEventListener( "load", frame, new EventListener() { public void handleEvent(Event event) { // This should never call synchronously. assert remover != null; assert !setConnected(true); listener.onConnected(Client.this); remover.remove(); } }); }