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

Unified Diff: LayoutTests/netinfo/unregister-during-event.html

Issue 291203002: Adds NetInfo v3 Web API to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@netinfo1
Patch Set: Simplified layout tests Created 6 years, 7 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: LayoutTests/netinfo/unregister-during-event.html
diff --git a/LayoutTests/netinfo/unregister-during-event.html b/LayoutTests/netinfo/unregister-during-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..50e0c61fcd3303129c94ab3edfaf61efb00917e5
--- /dev/null
+++ b/LayoutTests/netinfo/unregister-during-event.html
@@ -0,0 +1,30 @@
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script src="resources/netinfo_common.js"></script>
+</head>
+<body>
+<script>
+
+description("Tests that it's okay to unregister the event listener while handling the event.");
+
+var otherHandler = function(e) {
+ if (connection.type != initialType)
+ testFailed("The connection type did not revert.");
+ finishJSTest();
+};
+
+var handler = function(e) {
+ if (connection.type != newConnectionType)
+ testFailed("The connection type did not change.");
+ connection.removeEventListener('typechange', handler);
+ connection.addEventListener('typechange', otherHandler);
+ internals.setNetworkConnectionInfo(initialType);
+};
+
+connection.addEventListener('typechange', handler);
+internals.setNetworkConnectionInfo(newConnectionType);
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698