Ejemplo n.º 1
0
 /** @see com.aptana.ide.editors.unified.ContributedBrowser#execute(java.lang.String) */
 public boolean execute(String script) {
   nsIDOMDocument document = internalGetDocument();
   if (document != null) {
     nsIDOMElement se = document.createElement("script"); // $NON-NLS-1$
     nsIDOMHTMLScriptElement scriptBlock =
         (nsIDOMHTMLScriptElement)
             se.queryInterface(nsIDOMHTMLScriptElement.NS_IDOMHTMLSCRIPTELEMENT_IID);
     String s2 =
         "if("
             + script
             + "){"
             + "document.getElementById('execute').setAttribute('text','success');}"; //$NON-NLS-1$
                                                                                      // //$NON-NLS-2$ //$NON-NLS-3$
     scriptBlock.setText(s2);
     nsIDOMElement executeBlock = document.getElementById("execute"); // $NON-NLS-1$
     if (executeBlock == null) {
       executeBlock = document.createElement("div"); // $NON-NLS-1$
       executeBlock.setAttribute("id", "execute"); // $NON-NLS-1$ //$NON-NLS-2$
       nsIDOMNode body = document.getElementsByTagName("body").item(0); // $NON-NLS-1$
       body.appendChild(executeBlock);
     }
     executeBlock.setAttribute("text", ""); // $NON-NLS-1$ //$NON-NLS-2$
     nsIDOMNode head = document.getElementsByTagName("head").item(0); // $NON-NLS-1$
     head.appendChild(scriptBlock);
     executeBlock = document.getElementById("execute"); // $NON-NLS-1$
     return "success".equals(executeBlock.getAttribute("text")); // $NON-NLS-1$ //$NON-NLS-2$
   } else {
     return false;
   }
 }
Ejemplo n.º 2
0
  /**
   * Checks if the first element in the test file is selected in the VPE when the VPE is just
   * loaded.
   *
   * @throws Throwable
   */
  public void testJBIDE4037Test() throws Throwable {
    setException(null);
    IFile ifile = (IFile) TestUtil.getComponentPath(FILE_PATH, JsfAllTests.IMPORT_PROJECT_NAME);
    IEditorInput input = new FileEditorInput(ifile);
    JSPMultiPageEditor part = openEditor(input);

    TestUtil.waitForJobs();
    nsIDOMElement rootElement =
        TestUtil.getVpeController(part).getXulRunnerEditor().getSelectedElement();

    // check if something selected
    assertNotNull(rootElement);
    // check if the selected element is the first element on the page (we know its ID)
    assertEquals(ROOT_ELEMENT_ID, rootElement.getAttribute(HTML.ATTR_ID));

    if (getException() != null) {
      throw getException();
    }
  }