Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: ui/webui/resources/js/cr/event_target_test.html

Issue 17315020: Port passing closure tests for cr.ui framework to browser tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/js/cr/event_target_test.html
diff --git a/ui/webui/resources/js/cr/event_target_test.html b/ui/webui/resources/js/cr/event_target_test.html
deleted file mode 100644
index ec5f2f68695680e6d2ad1a4404c2180b59b45760..0000000000000000000000000000000000000000
--- a/ui/webui/resources/js/cr/event_target_test.html
+++ /dev/null
@@ -1,137 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<!-- TODO(arv): Check in Closue unit tests and make this run as part of the
- tests -->
-<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
-<script src="../cr.js"></script>
-<script src="event_target.js"></script>
-<script>
-
-goog.require('goog.testing.jsunit');
-
-</script>
-</head>
-<body>
-<script>
-
-const EventTarget = cr.EventTarget;
-const Event = cr.Event;
-
-function testFunctionListener() {
- var fi = 0;
- function f(e) {
- fi++;
- }
-
- var gi = 0;
- function g(e) {
- gi++;
- }
-
- var et = new EventTarget;
- et.addEventListener('f', f);
- et.addEventListener('g', g);
-
- // Adding again should not cause it to be called twice
- et.addEventListener('f', f);
- et.dispatchEvent(new Event('f'));
- assertEquals('Should have been called once', 1, fi);
- assertEquals(0, gi);
-
- et.removeEventListener('f', f);
- et.dispatchEvent(new Event('f'));
- assertEquals('Should not have been called again', 1, fi);
-
- et.dispatchEvent(new Event('g'));
- assertEquals('Should have been called once', 1, gi);
-}
-
-function testHandleEvent() {
- var fi = 0;
- var f = {
- handleEvent: function(e) {
- fi++;
- }
- };
-
- var gi = 0;
- var g = {
- handleEvent: function(e) {
- gi++;
- }
- };
-
- var et = new EventTarget;
- et.addEventListener('f', f);
- et.addEventListener('g', g);
-
- // Adding again should not cause it to be called twice
- et.addEventListener('f', f);
- et.dispatchEvent(new Event('f'));
- assertEquals('Should have been called once', 1, fi);
- assertEquals(0, gi);
-
- et.removeEventListener('f', f);
- et.dispatchEvent(new Event('f'));
- assertEquals('Should not have been called again', 1, fi);
-
- et.dispatchEvent(new Event('g'));
- assertEquals('Should have been called once', 1, gi);
-}
-
-function testPreventDefault() {
- var i = 0;
- function prevent(e) {
- i++;
- e.preventDefault();
- }
-
- var j = 0;
- function pass(e) {
- j++;
- }
-
- var et = new EventTarget;
- et.addEventListener('test', pass);
-
- assertTrue(et.dispatchEvent(new Event('test')));
- assertEquals(1, j);
-
- et.addEventListener('test', prevent);
-
- console.log('NOW');
- assertFalse(et.dispatchEvent(new Event('test')));
- assertEquals(2, j);
- assertEquals(1, i);
-}
-
-
-function testReturnFalse() {
- var i = 0;
- function prevent(e) {
- i++;
- return false;
- }
-
- var j = 0;
- function pass(e) {
- j++;
- }
-
- var et = new EventTarget;
- et.addEventListener('test', pass);
-
- assertTrue(et.dispatchEvent(new Event('test')));
- assertEquals(1, j);
-
- et.addEventListener('test', prevent);
-
- assertFalse(et.dispatchEvent(new Event('test')));
- assertEquals(2, j);
- assertEquals(1, i);
-}
-
-</script>
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698