Author: felix8a
Date: Wed Jul  8 13:25:21 2009
New Revision: 3562

Modified:
   trunk/src/com/google/caja/plugin/domita.js
   trunk/tests/com/google/caja/plugin/DomitaTest.java
   trunk/tests/com/google/caja/plugin/domita_test_untrusted.html

Log:
Enable input.blur() in domita
http://codereview.appspot.com/92041

1. domita has methods for focus() and blur(), but doesn't
make blur() callable.  This change makes blur() callable.

2. DomitaTest didn't clean up after a test failure.
A test failure would make subsequent tests fail to start.
This change adds cleanup.

[email protected]


Modified: trunk/src/com/google/caja/plugin/domita.js
==============================================================================
--- trunk/src/com/google/caja/plugin/domita.js  (original)
+++ trunk/src/com/google/caja/plugin/domita.js  Wed Jul  8 13:25:21 2009
@@ -2454,7 +2454,8 @@
       return newValue;
     };
     ___.all2(___.grantTypedMethod, TameInputElement.prototype,
- ['getValue', 'setValue', 'focus', 'getForm', 'getType', 'select']);
+             ['getValue', 'setValue', 'focus', 'blur',
+               'getForm', 'getType', 'select']);


     function TameImageElement(node, editable) {

Modified: trunk/tests/com/google/caja/plugin/DomitaTest.java
==============================================================================
--- trunk/tests/com/google/caja/plugin/DomitaTest.java  (original)
+++ trunk/tests/com/google/caja/plugin/DomitaTest.java Wed Jul 8 13:25:21 2009
@@ -69,11 +69,11 @@
   }

   public void testDomitaCajita() {
-    runPage("domita_test.html");
+    exercise("domita_test.html");
   }

   public void testDomitaValija() {
-    runPage("domita_test.html?valija=1");
+    exercise("domita_test.html?valija=1");
   }

   /**
@@ -81,9 +81,16 @@
    * Repeat until all tests are passed, or the number of rounds exceeds the
    * threshold.
    */
-  public void runPage(String pageName) {
+  public void exercise(String pageName) {
     StartLocalServer();
+    try {
+      exerciseFirefox(pageName);
+    } finally {
+      StopLocalServer();
+    }
+  }

+  void exerciseFirefox(String pageName) {
     //System.setProperty("webdriver.firefox.bin", "/usr/bin/firefox");
     WebDriver driver = new FirefoxDriver();

@@ -114,8 +121,5 @@
     String title = driver.getTitle();
assertTrue("The title shows " + title.substring(title.lastIndexOf("-") + 1),
         title.endsWith("all tests passed"));
-
-    //driver.quit();
-    StopLocalServer();
   }
 }

Modified: trunk/tests/com/google/caja/plugin/domita_test_untrusted.html
==============================================================================
--- trunk/tests/com/google/caja/plugin/domita_test_untrusted.html       
(original)
+++ trunk/tests/com/google/caja/plugin/domita_test_untrusted.html Wed Jul 8 13:25:21 2009
@@ -311,6 +311,10 @@
   </table>
 </div>

+<p class="testcontainer" id="test-focus-blur"
+ ><input id="test-focus-blur-1">
+</p>
+
 <p class="testcontainer" id="test-document-body-appendChild"
>I should be the last element until something is appended to document.body</p>

@@ -2304,6 +2308,15 @@
   assertEquals('body changed', body, document.body);
   assertEquals('parent is not body', lastest.parentNode, body);
   pass('test-document-body-appendChild');
+});
+
+jsunitRegister('testFocusBlur',
+               function testFocusBlur() {
+  var input = document.getElementById('test-focus-blur-1');
+  input.focus();
+  input.blur();
+  // TODO: verify focus does change.  requires an event-driven tester.
+  pass('test-focus-blur');
 });

 // Before onload events fire

Reply via email to