Revision: 5437
Author: [email protected]
Date: Tue Jun 4 12:20:57 2013
Log: fix test-domado-events flakiness
https://codereview.appspot.com/9798051
test-domado-events in any flavor occasionally has 2 failures because
of a timing issue.
The test driver gets a list of all clickable elements, clicks on
each one, then repeats that process.
testHandlerAttributeArguments as written requires two different
click handlers to fire before it passes.
How it fails:
- driver gets list of elements, including elem1 and elem2
- driver clicks elem1, which doesn't have a click handler installed yet
- jsunit runs testHandlerAttributeArguments, which installs the handlers
- driver clicks elem2, triggering half of the pass condition
- driver rescans for elements to click, including elem1 and elem2
- driver clicks elem1, triggering the other half of the pass condition
- driver clicks elem2, triggering pass a second time, which is an error
the fix is to split the test into two separate tests
R=kpreid2
http://code.google.com/p/google-caja/source/detail?r=5437
Modified:
/trunk/tests/com/google/caja/plugin/es53-test-domado-events-guest.html
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-domado-events-guest.html
Tue Apr 30 11:03:00 2013
+++ /trunk/tests/com/google/caja/plugin/es53-test-domado-events-guest.html
Tue Jun 4 12:20:57 2013
@@ -195,28 +195,34 @@
});
</script>
-<div class="clickme testcontainer" id="testHandlerAttributeArguments">
- testHandlerAttributeArguments -- Handler-called functions should not get
+<div class="clickme testcontainer" id="testHandlerAttributeArguments0">
+ testHandlerAttributeArguments0 -- Handler-called functions should not get
extra parameters.
- <div id="testHandlerAttributeArguments-0"><b>click me: 0 args</b></div>
- <div id="testHandlerAttributeArguments-2"><b>click me: 2 args</b></div>
+ <div id="testHandlerAttributeArguments0-div"><b>click me: 0
args</b></div>
</div>
<script type="text/javascript">
- jsunitRegister('testHandlerAttributeArguments',
- function testHandlerAttributeArguments() {
- var ok0 = false, ok2 = false;
-
- document.getElementById('testHandlerAttributeArguments-0')
+ jsunitRegister('testHandlerAttributeArguments0',
+ function testHandlerAttributeArguments0() {
+ document.getElementById('testHandlerAttributeArguments0-div')
.setAttribute('onclick', 'testHandlerAttributeArguments_go0();');
window.testHandlerAttributeArguments_go0 = jsunitCallback(
function handlerCalledFn() {
console.log('go0', Array.prototype.slice.call(arguments));
assertEquals('length', 0, arguments.length);
- ok0 = true;
- if (ok0 && ok2) { pass('testHandlerAttributeArguments'); }
+ pass('testHandlerAttributeArguments0');
});
+ });
+</script>
- document.getElementById('testHandlerAttributeArguments-2')
+<div class="clickme testcontainer" id="testHandlerAttributeArguments2">
+ testHandlerAttributeArguments2 -- Handler-called functions should not get
+ extra parameters.
+ <div id="testHandlerAttributeArguments2-div"><b>click me: 2
args</b></div>
+</div>
+<script>
+ jsunitRegister('testHandlerAttributeArguments2',
+ function testHandlerAttributeArguments2() {
+ document.getElementById('testHandlerAttributeArguments2-div')
.setAttribute('onclick',
'testHandlerAttributeArguments_go2(event, this);');
window.testHandlerAttributeArguments_go2 = jsunitCallback(
@@ -225,9 +231,8 @@
assertEquals('length', 2, arguments.length);
assertTrue('first arg', arguments[0] instanceof Event);
assertTrue('second arg', arguments[1] ===
- document.getElementById('testHandlerAttributeArguments-2'));
- ok2 = true;
- if (ok0 && ok2) { pass('testHandlerAttributeArguments'); }
+
document.getElementById('testHandlerAttributeArguments2-div'));
+ pass('testHandlerAttributeArguments2');
});
});
</script>
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.