{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/50261419","id":50261419,"diff_hunk":"@@ -0,0 +1,107 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+import Foundation\n+import WebKit\n+\n+class FindInPageTests: KIFTestCase {\n+    private static let LongPressDuration: NSTimeInterval = 2\n+\n+    private var webRoot: String!\n+\n+    override func setUp() {\n+        webRoot = SimplePageServer.start()\n+    }\n+\n+    func testFindFromSelection() {\n+        let testURL = \"\\(webRoot)/findPage.html\"\n+\n+        tester().tapViewWithAccessibilityIdentifier(\"url\")\n+        tester().clearTextFromAndThenEnterTextIntoCurrentFirstResponder(\"\\(testURL)\\n\")\n+        let webView = tester().waitForViewWithAccessibilityLabel(\"Web content\") as! WKWebView\n+        tester().waitForWebViewElementWithAccessibilityLabel(\"nullam\")\n+\n+        // Ensure the find-in-page bar is visible by looking at views.\n+        openFindInPageBar(webView)\n+        XCTAssertTrue(viewExists(\"Done\"))\n+        XCTAssertTrue(viewExists(\"Next in-page result\"))\n+        XCTAssertTrue(viewExists(\"Previous in-page result\"))\n+\n+        // Test previous/next buttons.\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"1/4\")\n+        clickFindNext()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"2/4\")\n+        clickFindNext()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"3/4\")\n+        clickFindNext()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"4/4\")\n+        clickFindNext()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"1/4\")\n+        clickFindPrevious()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"4/4\")\n+        clickFindPrevious()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"3/4\")\n+        clickFindPrevious()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"2/4\")\n+        clickFindPrevious()\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"1/4\")\n+\n+        // Test a query with no matches.\n+        let findTextField = tester().waitForViewWithAccessibilityValue(\"nullam\") as! UITextField\n+        findTextField.becomeFirstResponder()\n+        tester().enterTextIntoCurrentFirstResponder(\"z\")\n+        let resultsView = tester().waitForViewWithAccessibilityLabel(\"0/0\")\n+        XCTAssertFalse(resultsView.hidden)\n+        tester().clearTextFromFirstResponder()\n+        XCTAssertTrue(resultsView.hidden)\n+\n+        // Make sure the selection menu still works with the bar already visible.\n+        openFindInPageBar(webView)\n+        try! tester().tryFindingViewWithAccessibilityLabel(\"1/4\")\n+\n+        // Make sure the bar disappears when reloading.\n+        tester().tapViewWithAccessibilityLabel(\"Reload\")\n+        tester().waitForAbsenceOfViewWithAccessibilityLabel(\"nullam\")\n+\n+        // Make sure the bar disappears when opening the tabs tray.\n+        openFindInPageBar(webView)\n+        tester().tapViewWithAccessibilityLabel(\"Show Tabs\")\n+        tester().tapViewWithAccessibilityLabel(\"Find Page\")\n+        tester().waitForAbsenceOfViewWithAccessibilityLabel(\"nullam\")\n+\n+        // Test that Done dismisses the toolbar.\n+        openFindInPageBar(webView)\n+        tester().tapViewWithAccessibilityLabel(\"Done\")\n+        XCTAssertFalse(viewExists(\"Done\"))\n+        XCTAssertFalse(viewExists(\"Next in-page result\"))\n+        XCTAssertFalse(viewExists(\"Previous in-page result\"))\n+    }\n+\n+    private func openFindInPageBar(webView: WKWebView) {\n+        // Make the selection menu appear. To keep things simple, the page has absolutely\n+        // positioned text at the top-left corner.\n+        webView.longPressAtPoint(CGPointZero, duration: FindInPageTests.LongPressDuration)\n+        webView.tapAtPoint(CGPointZero)\n+        tester().tapViewWithAccessibilityLabel(\"Find in Page\")\n+        tester().waitForViewWithAccessibilityValue(\"nullam\")\n+    }\n+\n+    private func clickFindNext() {\n+        tester().tapViewWithAccessibilityLabel(\"Next in-page result\")\n+    }\n+\n+    private func clickFindPrevious() {\n+        tester().tapViewWithAccessibilityLabel(\"Previous in-page result\")\n+    }\n+\n+    private func viewExists(label: String) -> Bool {","path":"UITests/FindInPageTests.swift","position":98,"original_position":98,"commit_id":"974a2013be947e026610256515977734901c2d95","original_commit_id":"974a2013be947e026610256515977734901c2d95","user":{"login":"sleroux","id":434322,"avatar_url":"https://avatars.githubusercontent.com/u/434322?v=3","gravatar_id":"","url":"https://api.github.com/users/sleroux","html_url":"https://github.com/sleroux","followers_url":"https://api.github.com/users/sleroux/followers","following_url":"https://api.github.com/users/sleroux/following{/other_user}","gists_url":"https://api.github.com/users/sleroux/gists{/gist_id}","starred_url":"https://api.github.com/users/sleroux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleroux/subscriptions","organizations_url":"https://api.github.com/users/sleroux/orgs","repos_url":"https://api.github.com/users/sleroux/repos","events_url":"https://api.github.com/users/sleroux/events{/privacy}","received_events_url":"https://api.github.com/users/sleroux/received_events","type":"User","site_admin":false},"body":"I like this method :+1: I keep finding myself using something like this in other UITests. Could we move it into a Utils class or tester extension?","created_at":"2016-01-20T14:42:42Z","updated_at":"2016-01-20T14:42:42Z","html_url":"https://github.com/mozilla/firefox-ios/pull/1453#discussion_r50261419","pull_request_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453","_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/50261419"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/1453#discussion_r50261419"},"pull_request":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453","id":56520063,"html_url":"https://github.com/mozilla/firefox-ios/pull/1453","diff_url":"https://github.com/mozilla/firefox-ios/pull/1453.diff","patch_url":"https://github.com/mozilla/firefox-ios/pull/1453.patch","issue_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/1453","number":1453,"state":"open","locked":false,"title":"Bug 1235882 - Find in page tests","user":{"login":"thebnich","id":1093266,"avatar_url":"https://avatars.githubusercontent.com/u/1093266?v=3","gravatar_id":"","url":"https://api.github.com/users/thebnich","html_url":"https://github.com/thebnich","followers_url":"https://api.github.com/users/thebnich/followers","following_url":"https://api.github.com/users/thebnich/following{/other_user}","gists_url":"https://api.github.com/users/thebnich/gists{/gist_id}","starred_url":"https://api.github.com/users/thebnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebnich/subscriptions","organizations_url":"https://api.github.com/users/thebnich/orgs","repos_url":"https://api.github.com/users/thebnich/repos","events_url":"https://api.github.com/users/thebnich/events{/privacy}","received_events_url":"https://api.github.com/users/thebnich/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-19T20:22:50Z","updated_at":"2016-01-20T14:42:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82cbf8eb0d3ee6532d63450ca08a0a9cd91bf9ec","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453/commits","review_comments_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453/comments","review_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/1453/comments","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/974a2013be947e026610256515977734901c2d95","head":{"label":"thebnich:find-in-page-tests","ref":"find-in-page-tests","sha":"974a2013be947e026610256515977734901c2d95","user":{"login":"thebnich","id":1093266,"avatar_url":"https://avatars.githubusercontent.com/u/1093266?v=3","gravatar_id":"","url":"https://api.github.com/users/thebnich","html_url":"https://github.com/thebnich","followers_url":"https://api.github.com/users/thebnich/followers","following_url":"https://api.github.com/users/thebnich/following{/other_user}","gists_url":"https://api.github.com/users/thebnich/gists{/gist_id}","starred_url":"https://api.github.com/users/thebnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebnich/subscriptions","organizations_url":"https://api.github.com/users/thebnich/orgs","repos_url":"https://api.github.com/users/thebnich/repos","events_url":"https://api.github.com/users/thebnich/events{/privacy}","received_events_url":"https://api.github.com/users/thebnich/received_events","type":"User","site_admin":false},"repo":{"id":27744299,"name":"firefox-ios","full_name":"thebnich/firefox-ios","owner":{"login":"thebnich","id":1093266,"avatar_url":"https://avatars.githubusercontent.com/u/1093266?v=3","gravatar_id":"","url":"https://api.github.com/users/thebnich","html_url":"https://github.com/thebnich","followers_url":"https://api.github.com/users/thebnich/followers","following_url":"https://api.github.com/users/thebnich/following{/other_user}","gists_url":"https://api.github.com/users/thebnich/gists{/gist_id}","starred_url":"https://api.github.com/users/thebnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebnich/subscriptions","organizations_url":"https://api.github.com/users/thebnich/orgs","repos_url":"https://api.github.com/users/thebnich/repos","events_url":"https://api.github.com/users/thebnich/events{/privacy}","received_events_url":"https://api.github.com/users/thebnich/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thebnich/firefox-ios","description":"Firefox for iOS","fork":true,"url":"https://api.github.com/repos/thebnich/firefox-ios","forks_url":"https://api.github.com/repos/thebnich/firefox-ios/forks","keys_url":"https://api.github.com/repos/thebnich/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thebnich/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thebnich/firefox-ios/teams","hooks_url":"https://api.github.com/repos/thebnich/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/thebnich/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/thebnich/firefox-ios/events","assignees_url":"https://api.github.com/repos/thebnich/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/thebnich/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/thebnich/firefox-ios/tags","blobs_url":"https://api.github.com/repos/thebnich/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thebnich/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thebnich/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/thebnich/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thebnich/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/thebnich/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/thebnich/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/thebnich/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/thebnich/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/thebnich/firefox-ios/subscription","commits_url":"https://api.github.com/repos/thebnich/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/thebnich/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/thebnich/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/thebnich/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/thebnich/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/thebnich/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thebnich/firefox-ios/merges","archive_url":"https://api.github.com/repos/thebnich/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thebnich/firefox-ios/downloads","issues_url":"https://api.github.com/repos/thebnich/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/thebnich/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/thebnich/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/thebnich/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thebnich/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/thebnich/firefox-ios/releases{/id}","created_at":"2014-12-09T01:43:28Z","updated_at":"2015-02-20T01:57:25Z","pushed_at":"2016-01-19T20:22:29Z","git_url":"git://github.com/thebnich/firefox-ios.git","ssh_url":"git@github.com:thebnich/firefox-ios.git","clone_url":"https://github.com/thebnich/firefox-ios.git","svn_url":"https://github.com/thebnich/firefox-ios","homepage":"","size":38847,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"autocomplete-highlight"}},"base":{"label":"mozilla:master","ref":"master","sha":"f31a5ba6153d754ef90f962d6d133476424a33da","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","created_at":"2014-11-03T19:07:02Z","updated_at":"2016-01-20T11:30:51Z","pushed_at":"2016-01-20T13:04:19Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":116148,"stargazers_count":5218,"watchers_count":5218,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":948,"mirror_url":null,"open_issues_count":78,"forks":948,"open_issues":78,"watchers":5218,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/1453"},"issue":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/1453"},"comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/1453/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1453/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/firefox-ios/statuses/974a2013be947e026610256515977734901c2d95"}}}}