{"action":"created","comment":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/64536760","id":64536760,"diff_hunk":"@@ -0,0 +1,101 @@\n+'use strict';\n+\n+const util = require('util');\n+const q = require('q');\n+const debug = require('debug');\n+const StateError = require('../errors/state-error');\n+const temp = require('../temp');\n+\n+module.exports = class CoordValidator {\n+    /**\n+     * Constructor for CoordValidator\n+     * @param {Browser} browser session instance\n+     */\n+    constructor(browser) {\n+        this.log = debug('gemini:coord-validator:' + browser.id);\n+    }\n+\n+    /**\n+     * Validates compatibility of image and crop area coordinates before cropping\n+     * @param {Image} image - captured image\n+     * @param {Object} cropArea\n+     * @returns {Promise<StateError|undefined>}\n+     */\n+    validate(image, cropArea) {\n+        const imageSize = image.getSize();\n+        const bottom = cropArea.top + cropArea.height;\n+\n+        this.log('image size', imageSize);\n+        this.log('crop area', cropArea);\n+\n+        if (bottom > imageSize.height) {\n+            return this._reportHeightOutsideError(image, cropArea);\n+        }\n+\n+        if (isOutsideOfImage(imageSize, cropArea)) {\n+            return this._reportCommonOutsideError(image);\n+        }\n+\n+        return q();\n+    }\n+\n+    /**\n+     * Reports error if crop area is outside of image\n+     * @param image - captured image\n+     * @returns {Promise<StateError>}\n+     * @private\n+     */\n+    _reportCommonOutsideError(image) {\n+        this.log('crop area is outside of image');\n+        return this._reportError(\n+            'Can not capture specified region of the page\\n' +\n+            'The size of a region is larger then image, captured by browser\\n' +\n+            'Check that elements:\\n' +\n+            ' - does not overflows the document\\n' +\n+            ' - does not overflows browser viewport\\n ' +\n+            'Alternatively, you can increase browser window size using\\n' +\n+            '\"setWindowSize\" or \"windowSize\" option in config file.',\n+            image\n+        );\n+    }\n+\n+    /**\n+     * This case is handled specially because of Opera 12 browser.\n+     * Problem, described in error message occurs there much more often then\n+     * for other browsers and has different workaround\n+     * @param {Image} image - captured image\n+     * @param {Object} cropArea - crop area\n+     * @returns {Promise<StateError>}\n+     * @private\n+     */\n+    _reportHeightOutsideError(image, cropArea) {\n+        const imageSize = image.getSize();\n+        this.log('crop bottom is outside of image');\n+\n+        return this._reportError(util.format(\n+            'Failed to capture the element because it is positioned outside of the captured body. ' +\n+            'Most probably you are trying to capture an absolute positioned element which does not make body ' +\n+            'height to expand. To fix this place a tall enough <div> on the page to make body expand.\\n' +\n+            'Element position: %s, %s; size: %s, %s. Page screenshot size: %s, %s. ',\n+            cropArea.left,\n+            cropArea.top,\n+            cropArea.width,\n+            cropArea.height,\n+            imageSize.width,\n+            imageSize.height\n+        ), image);\n+    }\n+\n+    _reportError(message, image) {\n+        const path = temp.path({suffix: '.png'});\n+        const error = new StateError((message));\n+\n+        return image.save(path)\n+            .then(() => (error.imagePath = path))","path":"lib/capture-session/coord-validator.js","position":94,"original_position":94,"commit_id":"6e186ae8adf9fbaef0544d0b1705ca9bb7eab9e3","original_commit_id":"6e186ae8adf9fbaef0544d0b1705ca9bb7eab9e3","user":{"login":"j0tunn","id":7701229,"avatar_url":"https://avatars.githubusercontent.com/u/7701229?v=3","gravatar_id":"","url":"https://api.github.com/users/j0tunn","html_url":"https://github.com/j0tunn","followers_url":"https://api.github.com/users/j0tunn/followers","following_url":"https://api.github.com/users/j0tunn/following{/other_user}","gists_url":"https://api.github.com/users/j0tunn/gists{/gist_id}","starred_url":"https://api.github.com/users/j0tunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0tunn/subscriptions","organizations_url":"https://api.github.com/users/j0tunn/orgs","repos_url":"https://api.github.com/users/j0tunn/repos","events_url":"https://api.github.com/users/j0tunn/events{/privacy}","received_events_url":"https://api.github.com/users/j0tunn/received_events","type":"User","site_admin":false},"body":"а зачем здесь в скобки тело оборачивать?","created_at":"2016-05-25T08:50:33Z","updated_at":"2016-05-25T08:50:33Z","html_url":"https://github.com/gemini-testing/gemini/pull/473#discussion_r64536760","pull_request_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/473","_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/64536760"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/473#discussion_r64536760"},"pull_request":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/473"}}},"pull_request":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/473","id":71245980,"html_url":"https://github.com/gemini-testing/gemini/pull/473","diff_url":"https://github.com/gemini-testing/gemini/pull/473.diff","patch_url":"https://github.com/gemini-testing/gemini/pull/473.patch","issue_url":"https://api.github.com/repos/gemini-testing/gemini/issues/473","number":473,"state":"open","locked":false,"title":"Implement image processing option","user":{"login":"tormozz48","id":996162,"avatar_url":"https://avatars.githubusercontent.com/u/996162?v=3","gravatar_id":"","url":"https://api.github.com/users/tormozz48","html_url":"https://github.com/tormozz48","followers_url":"https://api.github.com/users/tormozz48/followers","following_url":"https://api.github.com/users/tormozz48/following{/other_user}","gists_url":"https://api.github.com/users/tormozz48/gists{/gist_id}","starred_url":"https://api.github.com/users/tormozz48/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tormozz48/subscriptions","organizations_url":"https://api.github.com/users/tormozz48/orgs","repos_url":"https://api.github.com/users/tormozz48/repos","events_url":"https://api.github.com/users/tormozz48/events{/privacy}","received_events_url":"https://api.github.com/users/tormozz48/received_events","type":"User","site_admin":false},"body":"All pr steps:\r\n\r\n* Add new gemini option `screenshotMode` which can have 3 available values:\r\n\r\n1. `fullpage`\r\n2. `viewport`\r\n3. `auto` (default)\r\n\r\n* Implement passing this option into CaptureSession class instance\r\n* Change logic of coordinates transform calculation depending on `screenshotMode` option value\r\n* Move coordinates validation logic from `CaptureSession` into separate module `coord-validator.js`\r\n* Move coordinates transformation logic into set of separate modules in `./transformer` dir.\r\n* Rewrites all tests for capture logic.\r\n\r\n@j0tunn @sipayRT @eGavr ","created_at":"2016-05-24T15:53:28Z","updated_at":"2016-05-25T08:50:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81feee588f09247400f9cb8ef80fc66b83b56f02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/473/commits","review_comments_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/473/comments","review_comment_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/issues/473/comments","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/6e186ae8adf9fbaef0544d0b1705ca9bb7eab9e3","head":{"label":"gemini-testing:image-processing-option","ref":"image-processing-option","sha":"6e186ae8adf9fbaef0544d0b1705ca9bb7eab9e3","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","deployments_url":"https://api.github.com/repos/gemini-testing/gemini/deployments","created_at":"2014-02-11T14:58:41Z","updated_at":"2016-05-24T12:14:23Z","pushed_at":"2016-05-24T18:07:11Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":"http://gemini-testing.github.io/gemini/","size":1794,"stargazers_count":582,"watchers_count":582,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":69,"mirror_url":null,"open_issues_count":72,"forks":69,"open_issues":72,"watchers":582,"default_branch":"master"}},"base":{"label":"gemini-testing:master","ref":"master","sha":"e691d2fabf638898cd179b66a0e702ad20d410ec","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","deployments_url":"https://api.github.com/repos/gemini-testing/gemini/deployments","created_at":"2014-02-11T14:58:41Z","updated_at":"2016-05-24T12:14:23Z","pushed_at":"2016-05-24T18:07:11Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":"http://gemini-testing.github.io/gemini/","size":1794,"stargazers_count":582,"watchers_count":582,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":69,"mirror_url":null,"open_issues_count":72,"forks":69,"open_issues":72,"watchers":582,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/473"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/473"},"issue":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/473"},"comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/473/comments"},"review_comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/473/comments"},"review_comment":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/473/commits"},"statuses":{"href":"https://api.github.com/repos/gemini-testing/gemini/statuses/6e186ae8adf9fbaef0544d0b1705ca9bb7eab9e3"}}}}
{"actor":{"display_login":"j0tunn"}}