{"action":"created","comment":{"url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/comments/40365586","id":40365586,"diff_hunk":"@@ -0,0 +1,194 @@\n+@TestOn('browser')\n+library polymer_elements.test.iron_behavior_active_state_test;\n+\n+import 'dart:async';\n+import 'dart:convert';\n+import 'dart:html';\n+import 'dart:js';\n+import 'package:polymer_interop/polymer_interop.dart';\n+import 'package:test/test.dart';\n+import 'package:web_components/web_components.dart';\n+import 'fixtures/iron_behavior_elements.dart';\n+import 'common.dart';\n+\n+main() async {\n+  await initWebComponents();\n+\n+  group('active-state', () {\n+    TestButton activeTarget;\n+\n+    setUp(() {\n+      activeTarget = fixture('TrivialActiveState');\n+    });\n+\n+    group('non-primary pointer input source', () {\n+      test('does not cause state to change', () {\n+        var rightClickMouseEvent = new CustomEvent('mousedown');\n+        new JsObject.fromBrowserObject(rightClickMouseEvent)['buttons'] = 2;\n+        activeTarget.dispatchEvent(rightClickMouseEvent);\n+        expect(activeTarget.pressed, false);\n+      });\n+    });\n+\n+    group('active state with toggles attribute', () {\n+      setUp(() {\n+        activeTarget = fixture('ToggleActiveState');\n+      });\n+\n+      group('when clicked', () {\n+        test('is activated', () {\n+          var done = new Completer();\n+          downAndUp(activeTarget, () {\n+            try {\n+              expect(activeTarget.getAttribute('active'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-pressed'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-pressed'), 'true');\n+              done.complete();\n+            } catch (e) {\n+              done.complete(e);\n+            }\n+          });\n+          return done.future;\n+        });\n+\n+        test('is deactivated by a subsequent click', () {\n+          var done = new Completer();\n+          downAndUp(activeTarget, () {\n+            downAndUp(activeTarget, () {\n+              try {\n+                expect(activeTarget.getAttribute('active'), isNull);\n+                expect(activeTarget.getAttribute('aria-pressed'), isNotNull);\n+                expect(activeTarget.getAttribute('aria-pressed'), 'false');\n+                done.complete();\n+              } catch (e) {\n+                done.complete(e);\n+              }\n+            });\n+          });\n+          return done.future;\n+        });\n+\n+        test('the correct aria attribute is set', () {\n+          var done = new Completer();\n+          activeTarget.ariaActiveAttribute = 'aria-checked';\n+          downAndUp(activeTarget, () {\n+            try {\n+              expect(activeTarget.getAttribute('active'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-checked'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-checked'), 'true');\n+              done.complete();\n+            } catch (e) {\n+              done.complete(e);\n+            }\n+          });\n+          return done.future;\n+        });\n+\n+        test('the aria attribute is updated correctly', () {\n+          var done = new Completer();\n+          activeTarget.ariaActiveAttribute = 'aria-checked';\n+          downAndUp(activeTarget, () {\n+            try {\n+              expect(activeTarget.getAttribute('active'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-checked'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-checked'), 'true');\n+\n+              activeTarget.ariaActiveAttribute = 'aria-pressed';\n+              expect(activeTarget.getAttribute('aria-checked'), isNull);\n+              expect(activeTarget.getAttribute('aria-pressed'), isNotNull);\n+              expect(activeTarget.getAttribute('aria-pressed'), 'true');\n+              done.complete();\n+            } catch (e) {\n+              done.complete(e);\n+            }\n+          });\n+          return done.future;\n+        });\n+      });\n+    });\n+\n+    group('without toggles attribute', () {\n+      group('when mouse is down', () {\n+        test('does not get an active attribute', () {\n+          expect(activeTarget.getAttribute('active'), isNull);\n+          down(activeTarget);\n+          expect(activeTarget.getAttribute('active'), isNull);\n+        });\n+      });\n+\n+      group('when mouse is up', () {\n+        test('does not get an active attribute', () {\n+          down(activeTarget);\n+          expect(activeTarget.getAttribute('active'), isNull);\n+          up(activeTarget);\n+          expect(activeTarget.getAttribute('active'), isNull);\n+        });\n+      });\n+    });\n+\n+    group('when space is pressed', () {\n+      test('triggers a click event', () {\n+        var done = new Completer();\n+        activeTarget.on['click'].take(1).listen((_) {\n+          done.complete();\n+        });\n+        pressSpace(activeTarget);\n+        return done.future;\n+      });\n+\n+      test('only triggers click after the key is released', () {\n+        var done = new Completer();\n+        var keyupTriggered = false;\n+\n+        activeTarget.on['keyup'].take(1).listen((_) {\n+          keyupTriggered = true;\n+        });\n+\n+        activeTarget.on['click'].take(1).listen((_) {\n+          try {\n+            expect(keyupTriggered, true);\n+            done.complete();\n+          } catch (e) {\n+            done.complete(e);\n+          }\n+        });\n+\n+        pressSpace(activeTarget);\n+        return done.future;\n+      });\n+    });\n+\n+    group('when enter is pressed', () {\n+      test('triggers a click event', () {\n+        var done = new Completer();\n+        activeTarget.on['click'].take(1).listen((_) {","path":"test/iron_behavior_active_state_test.dart","position":164,"original_position":164,"commit_id":"158f8c79baa457140bf472a185d3520361824668","original_commit_id":"158f8c79baa457140bf472a185d3520361824668","user":{"login":"sigmundch","id":2049220,"avatar_url":"https://avatars.githubusercontent.com/u/2049220?v=3","gravatar_id":"","url":"https://api.github.com/users/sigmundch","html_url":"https://github.com/sigmundch","followers_url":"https://api.github.com/users/sigmundch/followers","following_url":"https://api.github.com/users/sigmundch/following{/other_user}","gists_url":"https://api.github.com/users/sigmundch/gists{/gist_id}","starred_url":"https://api.github.com/users/sigmundch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigmundch/subscriptions","organizations_url":"https://api.github.com/users/sigmundch/orgs","repos_url":"https://api.github.com/users/sigmundch/repos","events_url":"https://api.github.com/users/sigmundch/events{/privacy}","received_events_url":"https://api.github.com/users/sigmundch/received_events","type":"User","site_admin":false},"body":"(also, any reason why not use onClick instead of on['click'] (similarly with other events?)","created_at":"2015-09-24T20:03:11Z","updated_at":"2015-09-24T20:03:11Z","html_url":"https://github.com/dart-lang/polymer_elements/pull/61#discussion_r40365586","pull_request_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61","_links":{"self":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/comments/40365586"},"html":{"href":"https://github.com/dart-lang/polymer_elements/pull/61#discussion_r40365586"},"pull_request":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61"}}},"pull_request":{"url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61","id":45930522,"html_url":"https://github.com/dart-lang/polymer_elements/pull/61","diff_url":"https://github.com/dart-lang/polymer_elements/pull/61.diff","patch_url":"https://github.com/dart-lang/polymer_elements/pull/61.patch","issue_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/61","number":61,"state":"closed","locked":false,"title":"Behaviors!","user":{"login":"jakemac53","id":984921,"avatar_url":"https://avatars.githubusercontent.com/u/984921?v=3","gravatar_id":"","url":"https://api.github.com/users/jakemac53","html_url":"https://github.com/jakemac53","followers_url":"https://api.github.com/users/jakemac53/followers","following_url":"https://api.github.com/users/jakemac53/following{/other_user}","gists_url":"https://api.github.com/users/jakemac53/gists{/gist_id}","starred_url":"https://api.github.com/users/jakemac53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakemac53/subscriptions","organizations_url":"https://api.github.com/users/jakemac53/orgs","repos_url":"https://api.github.com/users/jakemac53/repos","events_url":"https://api.github.com/users/jakemac53/events{/privacy}","received_events_url":"https://api.github.com/users/jakemac53/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-24T18:14:16Z","updated_at":"2015-09-24T20:03:11Z","closed_at":"2015-09-24T18:14:40Z","merged_at":"2015-09-24T18:14:40Z","merge_commit_sha":"cee95d8b5bde7a954de25cbc7e84712f93a96928","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61/commits","review_comments_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61/comments","review_comment_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/61/comments","statuses_url":"https://api.github.com/repos/dart-lang/polymer_elements/statuses/158f8c79baa457140bf472a185d3520361824668","head":{"label":"dart-lang:behaviors","ref":"behaviors","sha":"158f8c79baa457140bf472a185d3520361824668","user":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":40261353,"name":"polymer_elements","full_name":"dart-lang/polymer_elements","owner":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dart-lang/polymer_elements","description":"","fork":false,"url":"https://api.github.com/repos/dart-lang/polymer_elements","forks_url":"https://api.github.com/repos/dart-lang/polymer_elements/forks","keys_url":"https://api.github.com/repos/dart-lang/polymer_elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dart-lang/polymer_elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dart-lang/polymer_elements/teams","hooks_url":"https://api.github.com/repos/dart-lang/polymer_elements/hooks","issue_events_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/events{/number}","events_url":"https://api.github.com/repos/dart-lang/polymer_elements/events","assignees_url":"https://api.github.com/repos/dart-lang/polymer_elements/assignees{/user}","branches_url":"https://api.github.com/repos/dart-lang/polymer_elements/branches{/branch}","tags_url":"https://api.github.com/repos/dart-lang/polymer_elements/tags","blobs_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dart-lang/polymer_elements/statuses/{sha}","languages_url":"https://api.github.com/repos/dart-lang/polymer_elements/languages","stargazers_url":"https://api.github.com/repos/dart-lang/polymer_elements/stargazers","contributors_url":"https://api.github.com/repos/dart-lang/polymer_elements/contributors","subscribers_url":"https://api.github.com/repos/dart-lang/polymer_elements/subscribers","subscription_url":"https://api.github.com/repos/dart-lang/polymer_elements/subscription","commits_url":"https://api.github.com/repos/dart-lang/polymer_elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/dart-lang/polymer_elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/dart-lang/polymer_elements/contents/{+path}","compare_url":"https://api.github.com/repos/dart-lang/polymer_elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dart-lang/polymer_elements/merges","archive_url":"https://api.github.com/repos/dart-lang/polymer_elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dart-lang/polymer_elements/downloads","issues_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues{/number}","pulls_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls{/number}","milestones_url":"https://api.github.com/repos/dart-lang/polymer_elements/milestones{/number}","notifications_url":"https://api.github.com/repos/dart-lang/polymer_elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dart-lang/polymer_elements/labels{/name}","releases_url":"https://api.github.com/repos/dart-lang/polymer_elements/releases{/id}","created_at":"2015-08-05T18:11:50Z","updated_at":"2015-09-15T16:03:19Z","pushed_at":"2015-09-24T19:57:06Z","git_url":"git://github.com/dart-lang/polymer_elements.git","ssh_url":"git@github.com:dart-lang/polymer_elements.git","clone_url":"https://github.com/dart-lang/polymer_elements.git","svn_url":"https://github.com/dart-lang/polymer_elements","homepage":null,"size":3959,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":15,"forks":6,"open_issues":15,"watchers":8,"default_branch":"master"}},"base":{"label":"dart-lang:master","ref":"master","sha":"23bc0a89e7e82def61fb0d1bda974d7ef58c2b64","user":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":40261353,"name":"polymer_elements","full_name":"dart-lang/polymer_elements","owner":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dart-lang/polymer_elements","description":"","fork":false,"url":"https://api.github.com/repos/dart-lang/polymer_elements","forks_url":"https://api.github.com/repos/dart-lang/polymer_elements/forks","keys_url":"https://api.github.com/repos/dart-lang/polymer_elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dart-lang/polymer_elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dart-lang/polymer_elements/teams","hooks_url":"https://api.github.com/repos/dart-lang/polymer_elements/hooks","issue_events_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/events{/number}","events_url":"https://api.github.com/repos/dart-lang/polymer_elements/events","assignees_url":"https://api.github.com/repos/dart-lang/polymer_elements/assignees{/user}","branches_url":"https://api.github.com/repos/dart-lang/polymer_elements/branches{/branch}","tags_url":"https://api.github.com/repos/dart-lang/polymer_elements/tags","blobs_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dart-lang/polymer_elements/statuses/{sha}","languages_url":"https://api.github.com/repos/dart-lang/polymer_elements/languages","stargazers_url":"https://api.github.com/repos/dart-lang/polymer_elements/stargazers","contributors_url":"https://api.github.com/repos/dart-lang/polymer_elements/contributors","subscribers_url":"https://api.github.com/repos/dart-lang/polymer_elements/subscribers","subscription_url":"https://api.github.com/repos/dart-lang/polymer_elements/subscription","commits_url":"https://api.github.com/repos/dart-lang/polymer_elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/dart-lang/polymer_elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/dart-lang/polymer_elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/dart-lang/polymer_elements/contents/{+path}","compare_url":"https://api.github.com/repos/dart-lang/polymer_elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dart-lang/polymer_elements/merges","archive_url":"https://api.github.com/repos/dart-lang/polymer_elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dart-lang/polymer_elements/downloads","issues_url":"https://api.github.com/repos/dart-lang/polymer_elements/issues{/number}","pulls_url":"https://api.github.com/repos/dart-lang/polymer_elements/pulls{/number}","milestones_url":"https://api.github.com/repos/dart-lang/polymer_elements/milestones{/number}","notifications_url":"https://api.github.com/repos/dart-lang/polymer_elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dart-lang/polymer_elements/labels{/name}","releases_url":"https://api.github.com/repos/dart-lang/polymer_elements/releases{/id}","created_at":"2015-08-05T18:11:50Z","updated_at":"2015-09-15T16:03:19Z","pushed_at":"2015-09-24T19:57:06Z","git_url":"git://github.com/dart-lang/polymer_elements.git","ssh_url":"git@github.com:dart-lang/polymer_elements.git","clone_url":"https://github.com/dart-lang/polymer_elements.git","svn_url":"https://github.com/dart-lang/polymer_elements","homepage":null,"size":3959,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":15,"forks":6,"open_issues":15,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61"},"html":{"href":"https://github.com/dart-lang/polymer_elements/pull/61"},"issue":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/issues/61"},"comments":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/dart-lang/polymer_elements/statuses/158f8c79baa457140bf472a185d3520361824668"}}}}