{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/comments/39923531","id":39923531,"diff_hunk":"@@ -0,0 +1,118 @@\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 file,\n+ * You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+\"use strict\";\n+\n+(function(exports) {\n+  const DATABASE_VERSION = 1;\n+  const DATABASE_NAME = \"NewTabData\";\n+\n+  const OBJECT_STORE_PREFS = \"prefs\";\n+  const PINNED_LINKS_PREF = \"pinnedLinks\";\n+\n+  const gUserDatabase = {\n+    _database: null,\n+\n+    init(mockDB) {\n+      return new Promise((resolve, reject) => {\n+        var db = mockDB || window.indexedDB;\n+        var request = db.open(DATABASE_NAME, DATABASE_VERSION);\n+\n+        request.onerror = event => {\n+          gUserDatabase._logError(event, \"Cannot open an indexedDB connection\");\n+          reject(new Error(event.target.errorCode));\n+        };\n+        request.onsuccess = event => {\n+          gUserDatabase._onDatabaseOpenSuccess(event).then(resolve);\n+        };\n+        request.onupgradeneeded = event => {\n+          gUserDatabase._onDatabaseUpgrade(event);\n+        };\n+      });\n+    },\n+\n+    save(objectStoreToWrite, objectStoreType, data, mockObjectStore) {\n+      return new Promise((resolve, reject) => {\n+        var transaction = gUserDatabase._database.transaction([objectStoreToWrite], \"readwrite\");\n+        var objectStore = mockObjectStore || transaction.objectStore(objectStoreToWrite);\n+\n+        var request = objectStore.get(objectStoreType);\n+        request.onsuccess = () => {\n+          gUserDatabase._onWriteFetchRequestSuccess(request, data, objectStore, objectStoreType).then(resolve, reject);\n+        };\n+        request.onerror = event => {\n+          gUserDatabase._logError(event, \"Failed to store object of type \" + objectStoreType);\n+          reject(new Error(event.target.errorCode));\n+        };\n+      });\n+    },\n+\n+    load(objectStoreToRead, objectStoreType) {\n+      return new Promise((resolve, reject) => {\n+        var transaction = gUserDatabase._database.transaction([objectStoreToRead]);\n+        var objectStore = transaction.objectStore(objectStoreToRead);\n+        var request = objectStore.get(objectStoreType);\n+        var transactionDescription = \"Load data \" + objectStoreType;\n+        gUserDatabase._setSimpleRequestHandlers(request, transactionDescription).then(resolve, reject);\n+      });\n+    },\n+\n+    _logError(event, errorString) {","path":"js/userDatabase.js","position":61,"original_position":61,"commit_id":"4c92aa99d34ca33dfd65575e5070f6e1bad7c7d8","original_commit_id":"4c92aa99d34ca33dfd65575e5070f6e1bad7c7d8","user":{"login":"marcoscaceres","id":870154,"avatar_url":"https://avatars.githubusercontent.com/u/870154?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoscaceres","html_url":"https://github.com/marcoscaceres","followers_url":"https://api.github.com/users/marcoscaceres/followers","following_url":"https://api.github.com/users/marcoscaceres/following{/other_user}","gists_url":"https://api.github.com/users/marcoscaceres/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoscaceres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoscaceres/subscriptions","organizations_url":"https://api.github.com/users/marcoscaceres/orgs","repos_url":"https://api.github.com/users/marcoscaceres/repos","events_url":"https://api.github.com/users/marcoscaceres/events{/privacy}","received_events_url":"https://api.github.com/users/marcoscaceres/received_events","type":"User","site_admin":false},"body":"The problem with this function is that it doesn't show us the context of the error (i.e., where the error actually happened. I would suggest dropping _logError and just console.log() the error in place). ","created_at":"2015-09-19T20:42:27Z","updated_at":"2015-09-19T20:42:27Z","html_url":"https://github.com/mozilla/remote-newtab/pull/74#discussion_r39923531","pull_request_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/comments/39923531"},"html":{"href":"https://github.com/mozilla/remote-newtab/pull/74#discussion_r39923531"},"pull_request":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74","id":44493341,"html_url":"https://github.com/mozilla/remote-newtab/pull/74","diff_url":"https://github.com/mozilla/remote-newtab/pull/74.diff","patch_url":"https://github.com/mozilla/remote-newtab/pull/74.patch","issue_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/74","number":74,"state":"open","locked":false,"title":"Index DB for pinned links.","user":{"login":"emtwo","id":784781,"avatar_url":"https://avatars.githubusercontent.com/u/784781?v=3","gravatar_id":"","url":"https://api.github.com/users/emtwo","html_url":"https://github.com/emtwo","followers_url":"https://api.github.com/users/emtwo/followers","following_url":"https://api.github.com/users/emtwo/following{/other_user}","gists_url":"https://api.github.com/users/emtwo/gists{/gist_id}","starred_url":"https://api.github.com/users/emtwo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emtwo/subscriptions","organizations_url":"https://api.github.com/users/emtwo/orgs","repos_url":"https://api.github.com/users/emtwo/repos","events_url":"https://api.github.com/users/emtwo/events{/privacy}","received_events_url":"https://api.github.com/users/emtwo/received_events","type":"User","site_admin":false},"body":"* Moved over `gPinnedLinks` from `NewTabUtils` in Firefox\r\n* Replaced prefs storage with indexedDB storage","created_at":"2015-09-08T22:59:04Z","updated_at":"2015-09-19T20:42:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aef5f906466215fcdc04dc41d1b5044aa535c2b8","assignee":null,"milestone":{"url":"https://api.github.com/repos/mozilla/remote-newtab/milestones/1","html_url":"https://github.com/mozilla/remote-newtab/milestones/19%20Sept.","labels_url":"https://api.github.com/repos/mozilla/remote-newtab/milestones/1/labels","id":1304834,"number":1,"title":"19 Sept.","description":"","creator":{"login":"marcoscaceres","id":870154,"avatar_url":"https://avatars.githubusercontent.com/u/870154?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoscaceres","html_url":"https://github.com/marcoscaceres","followers_url":"https://api.github.com/users/marcoscaceres/followers","following_url":"https://api.github.com/users/marcoscaceres/following{/other_user}","gists_url":"https://api.github.com/users/marcoscaceres/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoscaceres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoscaceres/subscriptions","organizations_url":"https://api.github.com/users/marcoscaceres/orgs","repos_url":"https://api.github.com/users/marcoscaceres/repos","events_url":"https://api.github.com/users/marcoscaceres/events{/privacy}","received_events_url":"https://api.github.com/users/marcoscaceres/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2015-09-14T17:28:14Z","updated_at":"2015-09-14T17:29:57Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74/commits","review_comments_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74/comments","review_comment_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/74/comments","statuses_url":"https://api.github.com/repos/mozilla/remote-newtab/statuses/4c92aa99d34ca33dfd65575e5070f6e1bad7c7d8","head":{"label":"mozilla:emtwo/indexDB","ref":"emtwo/indexDB","sha":"4c92aa99d34ca33dfd65575e5070f6e1bad7c7d8","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":40678245,"name":"remote-newtab","full_name":"mozilla/remote-newtab","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/remote-newtab","description":"Remotely-hosted New Tab Page","fork":false,"url":"https://api.github.com/repos/mozilla/remote-newtab","forks_url":"https://api.github.com/repos/mozilla/remote-newtab/forks","keys_url":"https://api.github.com/repos/mozilla/remote-newtab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/remote-newtab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/remote-newtab/teams","hooks_url":"https://api.github.com/repos/mozilla/remote-newtab/hooks","issue_events_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/remote-newtab/events","assignees_url":"https://api.github.com/repos/mozilla/remote-newtab/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/remote-newtab/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/remote-newtab/tags","blobs_url":"https://api.github.com/repos/mozilla/remote-newtab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/remote-newtab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/remote-newtab/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/remote-newtab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/remote-newtab/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/remote-newtab/languages","stargazers_url":"https://api.github.com/repos/mozilla/remote-newtab/stargazers","contributors_url":"https://api.github.com/repos/mozilla/remote-newtab/contributors","subscribers_url":"https://api.github.com/repos/mozilla/remote-newtab/subscribers","subscription_url":"https://api.github.com/repos/mozilla/remote-newtab/subscription","commits_url":"https://api.github.com/repos/mozilla/remote-newtab/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/remote-newtab/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/remote-newtab/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/remote-newtab/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/remote-newtab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/remote-newtab/merges","archive_url":"https://api.github.com/repos/mozilla/remote-newtab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/remote-newtab/downloads","issues_url":"https://api.github.com/repos/mozilla/remote-newtab/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/remote-newtab/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/remote-newtab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/remote-newtab/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/remote-newtab/releases{/id}","created_at":"2015-08-13T19:37:51Z","updated_at":"2015-08-25T20:43:34Z","pushed_at":"2015-09-18T15:42:38Z","git_url":"git://github.com/mozilla/remote-newtab.git","ssh_url":"git@github.com:mozilla/remote-newtab.git","clone_url":"https://github.com/mozilla/remote-newtab.git","svn_url":"https://github.com/mozilla/remote-newtab","homepage":"https://mozilla.github.io/remote-newtab/","size":838,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":27,"forks":0,"open_issues":27,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"mozilla:gh-pages","ref":"gh-pages","sha":"7241560b72f4e867fdd3fb10204c40a4c6211f73","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":40678245,"name":"remote-newtab","full_name":"mozilla/remote-newtab","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/remote-newtab","description":"Remotely-hosted New Tab Page","fork":false,"url":"https://api.github.com/repos/mozilla/remote-newtab","forks_url":"https://api.github.com/repos/mozilla/remote-newtab/forks","keys_url":"https://api.github.com/repos/mozilla/remote-newtab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/remote-newtab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/remote-newtab/teams","hooks_url":"https://api.github.com/repos/mozilla/remote-newtab/hooks","issue_events_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/remote-newtab/events","assignees_url":"https://api.github.com/repos/mozilla/remote-newtab/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/remote-newtab/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/remote-newtab/tags","blobs_url":"https://api.github.com/repos/mozilla/remote-newtab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/remote-newtab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/remote-newtab/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/remote-newtab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/remote-newtab/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/remote-newtab/languages","stargazers_url":"https://api.github.com/repos/mozilla/remote-newtab/stargazers","contributors_url":"https://api.github.com/repos/mozilla/remote-newtab/contributors","subscribers_url":"https://api.github.com/repos/mozilla/remote-newtab/subscribers","subscription_url":"https://api.github.com/repos/mozilla/remote-newtab/subscription","commits_url":"https://api.github.com/repos/mozilla/remote-newtab/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/remote-newtab/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/remote-newtab/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/remote-newtab/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/remote-newtab/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/remote-newtab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/remote-newtab/merges","archive_url":"https://api.github.com/repos/mozilla/remote-newtab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/remote-newtab/downloads","issues_url":"https://api.github.com/repos/mozilla/remote-newtab/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/remote-newtab/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/remote-newtab/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/remote-newtab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/remote-newtab/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/remote-newtab/releases{/id}","created_at":"2015-08-13T19:37:51Z","updated_at":"2015-08-25T20:43:34Z","pushed_at":"2015-09-18T15:42:38Z","git_url":"git://github.com/mozilla/remote-newtab.git","ssh_url":"git@github.com:mozilla/remote-newtab.git","clone_url":"https://github.com/mozilla/remote-newtab.git","svn_url":"https://github.com/mozilla/remote-newtab","homepage":"https://mozilla.github.io/remote-newtab/","size":838,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":27,"forks":0,"open_issues":27,"watchers":0,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74"},"html":{"href":"https://github.com/mozilla/remote-newtab/pull/74"},"issue":{"href":"https://api.github.com/repos/mozilla/remote-newtab/issues/74"},"comments":{"href":"https://api.github.com/repos/mozilla/remote-newtab/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/remote-newtab/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/remote-newtab/statuses/4c92aa99d34ca33dfd65575e5070f6e1bad7c7d8"}}}}