{"action":"created","comment":{"url":"https://api.github.com/repos/webrtc/adapter/pulls/comments/117162435","pull_request_review_id":38843975,"id":117162435,"diff_hunk":"@@ -0,0 +1,175 @@\n+/*\n+ *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.\n+ *\n+ *  Use of this source code is governed by a BSD-style license\n+ *  that can be found in the LICENSE file in the root of the source\n+ *  tree.\n+ */\n+/* eslint-env node */\n+const chai = require('chai');\n+const expect = chai.expect;\n+const sinon = require('sinon');\n+const sinonChai = require('sinon-chai');\n+chai.use(sinonChai);\n+\n+const utils = require('../../src/js/utils');\n+\n+describe('Chrome getUserMedia constraints converter', () => {\n+  const shim = require('../../src/js/chrome/getusermedia');\n+\n+  beforeEach(() => {\n+    global.window = global;\n+    window.navigator = {\n+      webkitGetUserMedia: sinon.stub(),\n+    };\n+    utils.browserDetails.browser = 'Chrome';\n+    utils.browserDetails.version = 51;\n+    shim();\n+  });\n+\n+  it('back-converts spec constraints', () => {\n+    window.navigator.getUserMedia({\n+      video: {\n+        width: 1280,\n+        height: {min: 200, ideal: 720, max: 1080},\n+        frameRate: {exact: 50}\n+      }\n+    });\n+    expect(window.navigator.webkitGetUserMedia).to.have.been.calledWith({\n+      video: {\n+        mandatory: {\n+          maxFrameRate: 50,\n+          maxHeight: 1080,\n+          minHeight: 200,\n+          minFrameRate: 50\n+        },\n+        optional: [\n+                {minWidth: 1280},\n+                {maxWidth: 1280},\n+                {minHeight: 720},\n+                {maxHeight: 720}\n+        ]\n+      }\n+    });\n+  });\n+\n+  it('passes legacy constraints through', () => {\n+    const legacy = {\n+      video: {\n+        mandatory: {\n+          maxFrameRate: 50,\n+          maxHeight: 1080,\n+          minHeight: 200,\n+          minFrameRate: 50\n+        },\n+        optional: [\n+                {minWidth: 1280},\n+                {maxWidth: 1280},\n+                {minHeight: 720},\n+                {maxHeight: 720}\n+        ]\n+      }\n+    };\n+    window.navigator.getUserMedia(legacy);\n+    expect(window.navigator.webkitGetUserMedia).to.have.been.calledWith(legacy);\n+  });\n+\n+  it('does not choke on common unknown constraints', () => {\n+    window.navigator.getUserMedia({\n+      video: {\n+        mediaSource: 'screen',\n+        advanced: [\n+                {facingMode: 'user'}\n+        ],\n+        require: ['height', 'frameRate']\n+      }\n+    });\n+    expect(window.navigator.webkitGetUserMedia).to.have.been.calledWith({\n+      video: {\n+        optional: [\n+                {facingMode: 'user'}\n+        ]\n+      }\n+    });\n+  });\n+});\n+\n+describe('Firefox getUserMedia constraints converter', () => {\n+  const shim = require('../../src/js/firefox/getusermedia');\n+\n+  beforeEach(() => {\n+    global.window = global;\n+    window.navigator = {\n+      mozGetUserMedia: sinon.stub(),\n+    };\n+    utils.browserDetails.browser = 'Firefox';\n+  });\n+\n+  describe('in Firefox 37', () => {\n+    beforeEach(() => {\n+      utils.browserDetails.version = 37;\n+      shim();\n+    });\n+\n+    it('converts spec-constraints to legacy constraints', () => {\n+      window.navigator.getUserMedia({\n+        video: {\n+          mediaSource: 'screen',\n+          width: 1280,\n+          height: {min: 200, ideal: 720, max: 1080},\n+          facingMode: 'user',\n+          frameRate: {exact: 50}\n+        }\n+      });\n+      expect(window.navigator.mozGetUserMedia).to.have.been.calledWith({\n+        video: {\n+          mediaSource: 'screen',\n+          height: {min: 200, max: 1080},\n+          frameRate: {max: 50, min: 50},\n+          advanced: [\n+                  {width: {min: 1280, max: 1280}},\n+                  {height: {min: 720, max: 720}},\n+                  {facingMode: 'user'}\n+          ],\n+          require: ['height', 'frameRate']\n+        }\n+      });\n+    });\n+\n+    it('passes legacy constraints through', () => {\n+      const legacy = {\n+        video: {\n+          height: {min: 200, max: 1080},\n+          frameRate: {max: 50, min: 50},\n+          advanced: [\n+                  {width: {min: 1280, max: 1280}},\n+                  {height: {min: 720, max: 720}},\n+                  {facingMode: 'user'}\n+          ],\n+          require: ['height', 'frameRate']\n+        }\n+      };\n+      window.navigator.getUserMedia(legacy);\n+      expect(window.navigator.mozGetUserMedia).to.have.been.calledWith(legacy);\n+    });\n+  });\n+\n+  describe('in Firefox 38+', () => {\n+    beforeEach(() => {\n+      utils.browserDetails.version = 53;","path":"test/unit/getusermedia-constraints.js","position":null,"original_position":159,"commit_id":"7e558495e1b48a8dd3677c9a3013050d9dbc5b20","original_commit_id":"651e450cd288fbedcd97393a2c1069627dded880","user":{"login":"fippo","id":289731,"avatar_url":"https://avatars2.githubusercontent.com/u/289731?v=3","gravatar_id":"","url":"https://api.github.com/users/fippo","html_url":"https://github.com/fippo","followers_url":"https://api.github.com/users/fippo/followers","following_url":"https://api.github.com/users/fippo/following{/other_user}","gists_url":"https://api.github.com/users/fippo/gists{/gist_id}","starred_url":"https://api.github.com/users/fippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fippo/subscriptions","organizations_url":"https://api.github.com/users/fippo/orgs","repos_url":"https://api.github.com/users/fippo/repos","events_url":"https://api.github.com/users/fippo/events{/privacy}","received_events_url":"https://api.github.com/users/fippo/received_events","type":"User","site_admin":false},"body":"changeed","created_at":"2017-05-18T05:15:52Z","updated_at":"2017-05-18T05:15:52Z","html_url":"https://github.com/webrtc/adapter/pull/550#discussion_r117162435","pull_request_url":"https://api.github.com/repos/webrtc/adapter/pulls/550","_links":{"self":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/comments/117162435"},"html":{"href":"https://github.com/webrtc/adapter/pull/550#discussion_r117162435"},"pull_request":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/550"}}},"pull_request":{"url":"https://api.github.com/repos/webrtc/adapter/pulls/550","id":120989662,"html_url":"https://github.com/webrtc/adapter/pull/550","diff_url":"https://github.com/webrtc/adapter/pull/550.diff","patch_url":"https://github.com/webrtc/adapter/pull/550.patch","issue_url":"https://api.github.com/repos/webrtc/adapter/issues/550","number":550,"state":"open","locked":false,"title":"test: use unit tests for getUserMedia constraints converter","user":{"login":"fippo","id":289731,"avatar_url":"https://avatars2.githubusercontent.com/u/289731?v=3","gravatar_id":"","url":"https://api.github.com/users/fippo","html_url":"https://github.com/fippo","followers_url":"https://api.github.com/users/fippo/followers","following_url":"https://api.github.com/users/fippo/following{/other_user}","gists_url":"https://api.github.com/users/fippo/gists{/gist_id}","starred_url":"https://api.github.com/users/fippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fippo/subscriptions","organizations_url":"https://api.github.com/users/fippo/orgs","repos_url":"https://api.github.com/users/fippo/repos","events_url":"https://api.github.com/users/fippo/events{/privacy}","received_events_url":"https://api.github.com/users/fippo/received_events","type":"User","site_admin":false},"body":"uses sinon.stub to make assertions about how the constraints\r\nconverter works in different browsers and versions.\r\n\r\n@jan-ivar PTAL -- this was one of the more scary tests, I find this a bit easier to reason about.\r\nIIRC this test was one of the reasons we are still using webkitGetUserMedia.","created_at":"2017-05-17T07:22:00Z","updated_at":"2017-05-18T05:15:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dedb0ee937a12d4991830c33c14fdae8051233f4","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/webrtc/adapter/pulls/550/commits","review_comments_url":"https://api.github.com/repos/webrtc/adapter/pulls/550/comments","review_comment_url":"https://api.github.com/repos/webrtc/adapter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/webrtc/adapter/issues/550/comments","statuses_url":"https://api.github.com/repos/webrtc/adapter/statuses/7e558495e1b48a8dd3677c9a3013050d9dbc5b20","head":{"label":"fippo:move-constraint-tests","ref":"move-constraint-tests","sha":"7e558495e1b48a8dd3677c9a3013050d9dbc5b20","user":{"login":"fippo","id":289731,"avatar_url":"https://avatars2.githubusercontent.com/u/289731?v=3","gravatar_id":"","url":"https://api.github.com/users/fippo","html_url":"https://github.com/fippo","followers_url":"https://api.github.com/users/fippo/followers","following_url":"https://api.github.com/users/fippo/following{/other_user}","gists_url":"https://api.github.com/users/fippo/gists{/gist_id}","starred_url":"https://api.github.com/users/fippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fippo/subscriptions","organizations_url":"https://api.github.com/users/fippo/orgs","repos_url":"https://api.github.com/users/fippo/repos","events_url":"https://api.github.com/users/fippo/events{/privacy}","received_events_url":"https://api.github.com/users/fippo/received_events","type":"User","site_admin":false},"repo":{"id":30330866,"name":"adapter","full_name":"fippo/adapter","owner":{"login":"fippo","id":289731,"avatar_url":"https://avatars2.githubusercontent.com/u/289731?v=3","gravatar_id":"","url":"https://api.github.com/users/fippo","html_url":"https://github.com/fippo","followers_url":"https://api.github.com/users/fippo/followers","following_url":"https://api.github.com/users/fippo/following{/other_user}","gists_url":"https://api.github.com/users/fippo/gists{/gist_id}","starred_url":"https://api.github.com/users/fippo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fippo/subscriptions","organizations_url":"https://api.github.com/users/fippo/orgs","repos_url":"https://api.github.com/users/fippo/repos","events_url":"https://api.github.com/users/fippo/events{/privacy}","received_events_url":"https://api.github.com/users/fippo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fippo/adapter","description":"working copy of webrtc/adapter. File issues for Edge stuff here","fork":true,"url":"https://api.github.com/repos/fippo/adapter","forks_url":"https://api.github.com/repos/fippo/adapter/forks","keys_url":"https://api.github.com/repos/fippo/adapter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fippo/adapter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fippo/adapter/teams","hooks_url":"https://api.github.com/repos/fippo/adapter/hooks","issue_events_url":"https://api.github.com/repos/fippo/adapter/issues/events{/number}","events_url":"https://api.github.com/repos/fippo/adapter/events","assignees_url":"https://api.github.com/repos/fippo/adapter/assignees{/user}","branches_url":"https://api.github.com/repos/fippo/adapter/branches{/branch}","tags_url":"https://api.github.com/repos/fippo/adapter/tags","blobs_url":"https://api.github.com/repos/fippo/adapter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fippo/adapter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fippo/adapter/git/refs{/sha}","trees_url":"https://api.github.com/repos/fippo/adapter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fippo/adapter/statuses/{sha}","languages_url":"https://api.github.com/repos/fippo/adapter/languages","stargazers_url":"https://api.github.com/repos/fippo/adapter/stargazers","contributors_url":"https://api.github.com/repos/fippo/adapter/contributors","subscribers_url":"https://api.github.com/repos/fippo/adapter/subscribers","subscription_url":"https://api.github.com/repos/fippo/adapter/subscription","commits_url":"https://api.github.com/repos/fippo/adapter/commits{/sha}","git_commits_url":"https://api.github.com/repos/fippo/adapter/git/commits{/sha}","comments_url":"https://api.github.com/repos/fippo/adapter/comments{/number}","issue_comment_url":"https://api.github.com/repos/fippo/adapter/issues/comments{/number}","contents_url":"https://api.github.com/repos/fippo/adapter/contents/{+path}","compare_url":"https://api.github.com/repos/fippo/adapter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fippo/adapter/merges","archive_url":"https://api.github.com/repos/fippo/adapter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fippo/adapter/downloads","issues_url":"https://api.github.com/repos/fippo/adapter/issues{/number}","pulls_url":"https://api.github.com/repos/fippo/adapter/pulls{/number}","milestones_url":"https://api.github.com/repos/fippo/adapter/milestones{/number}","notifications_url":"https://api.github.com/repos/fippo/adapter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fippo/adapter/labels{/name}","releases_url":"https://api.github.com/repos/fippo/adapter/releases{/id}","deployments_url":"https://api.github.com/repos/fippo/adapter/deployments","created_at":"2015-02-05T01:20:35Z","updated_at":"2017-03-11T09:18:02Z","pushed_at":"2017-05-18T05:15:19Z","git_url":"git://github.com/fippo/adapter.git","ssh_url":"git@github.com:fippo/adapter.git","clone_url":"https://github.com/fippo/adapter.git","svn_url":"https://github.com/fippo/adapter","homepage":"","size":4243,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":11,"forks":3,"open_issues":11,"watchers":1,"default_branch":"master"}},"base":{"label":"webrtc:master","ref":"master","sha":"b4c552601358491baed431e518ff62ba0086d57f","user":{"login":"webrtc","id":10526312,"avatar_url":"https://avatars1.githubusercontent.com/u/10526312?v=3","gravatar_id":"","url":"https://api.github.com/users/webrtc","html_url":"https://github.com/webrtc","followers_url":"https://api.github.com/users/webrtc/followers","following_url":"https://api.github.com/users/webrtc/following{/other_user}","gists_url":"https://api.github.com/users/webrtc/gists{/gist_id}","starred_url":"https://api.github.com/users/webrtc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webrtc/subscriptions","organizations_url":"https://api.github.com/users/webrtc/orgs","repos_url":"https://api.github.com/users/webrtc/repos","events_url":"https://api.github.com/users/webrtc/events{/privacy}","received_events_url":"https://api.github.com/users/webrtc/received_events","type":"Organization","site_admin":false},"repo":{"id":30027163,"name":"adapter","full_name":"webrtc/adapter","owner":{"login":"webrtc","id":10526312,"avatar_url":"https://avatars1.githubusercontent.com/u/10526312?v=3","gravatar_id":"","url":"https://api.github.com/users/webrtc","html_url":"https://github.com/webrtc","followers_url":"https://api.github.com/users/webrtc/followers","following_url":"https://api.github.com/users/webrtc/following{/other_user}","gists_url":"https://api.github.com/users/webrtc/gists{/gist_id}","starred_url":"https://api.github.com/users/webrtc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webrtc/subscriptions","organizations_url":"https://api.github.com/users/webrtc/orgs","repos_url":"https://api.github.com/users/webrtc/repos","events_url":"https://api.github.com/users/webrtc/events{/privacy}","received_events_url":"https://api.github.com/users/webrtc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/webrtc/adapter","description":"Shim to insulate apps from spec changes and prefix differences. Latest adapter.js release:","fork":false,"url":"https://api.github.com/repos/webrtc/adapter","forks_url":"https://api.github.com/repos/webrtc/adapter/forks","keys_url":"https://api.github.com/repos/webrtc/adapter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webrtc/adapter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webrtc/adapter/teams","hooks_url":"https://api.github.com/repos/webrtc/adapter/hooks","issue_events_url":"https://api.github.com/repos/webrtc/adapter/issues/events{/number}","events_url":"https://api.github.com/repos/webrtc/adapter/events","assignees_url":"https://api.github.com/repos/webrtc/adapter/assignees{/user}","branches_url":"https://api.github.com/repos/webrtc/adapter/branches{/branch}","tags_url":"https://api.github.com/repos/webrtc/adapter/tags","blobs_url":"https://api.github.com/repos/webrtc/adapter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webrtc/adapter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webrtc/adapter/git/refs{/sha}","trees_url":"https://api.github.com/repos/webrtc/adapter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webrtc/adapter/statuses/{sha}","languages_url":"https://api.github.com/repos/webrtc/adapter/languages","stargazers_url":"https://api.github.com/repos/webrtc/adapter/stargazers","contributors_url":"https://api.github.com/repos/webrtc/adapter/contributors","subscribers_url":"https://api.github.com/repos/webrtc/adapter/subscribers","subscription_url":"https://api.github.com/repos/webrtc/adapter/subscription","commits_url":"https://api.github.com/repos/webrtc/adapter/commits{/sha}","git_commits_url":"https://api.github.com/repos/webrtc/adapter/git/commits{/sha}","comments_url":"https://api.github.com/repos/webrtc/adapter/comments{/number}","issue_comment_url":"https://api.github.com/repos/webrtc/adapter/issues/comments{/number}","contents_url":"https://api.github.com/repos/webrtc/adapter/contents/{+path}","compare_url":"https://api.github.com/repos/webrtc/adapter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webrtc/adapter/merges","archive_url":"https://api.github.com/repos/webrtc/adapter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webrtc/adapter/downloads","issues_url":"https://api.github.com/repos/webrtc/adapter/issues{/number}","pulls_url":"https://api.github.com/repos/webrtc/adapter/pulls{/number}","milestones_url":"https://api.github.com/repos/webrtc/adapter/milestones{/number}","notifications_url":"https://api.github.com/repos/webrtc/adapter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webrtc/adapter/labels{/name}","releases_url":"https://api.github.com/repos/webrtc/adapter/releases{/id}","deployments_url":"https://api.github.com/repos/webrtc/adapter/deployments","created_at":"2015-01-29T15:41:40Z","updated_at":"2017-05-17T18:34:12Z","pushed_at":"2017-05-18T05:15:20Z","git_url":"git://github.com/webrtc/adapter.git","ssh_url":"git@github.com:webrtc/adapter.git","clone_url":"https://github.com/webrtc/adapter.git","svn_url":"https://github.com/webrtc/adapter","homepage":"https://webrtc.github.io/adapter/adapter-latest.js","size":4297,"stargazers_count":825,"watchers_count":825,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":206,"mirror_url":null,"open_issues_count":28,"forks":206,"open_issues":28,"watchers":825,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/550"},"html":{"href":"https://github.com/webrtc/adapter/pull/550"},"issue":{"href":"https://api.github.com/repos/webrtc/adapter/issues/550"},"comments":{"href":"https://api.github.com/repos/webrtc/adapter/issues/550/comments"},"review_comments":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/550/comments"},"review_comment":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/webrtc/adapter/pulls/550/commits"},"statuses":{"href":"https://api.github.com/repos/webrtc/adapter/statuses/7e558495e1b48a8dd3677c9a3013050d9dbc5b20"}}}}
{"actor":{"display_login":"fippo"}}