diff --git a/core/modules/node/node.test b/core/modules/node/node.test
index 2e9b075..d97474d 100644
--- a/core/modules/node/node.test
+++ b/core/modules/node/node.test
@@ -2300,3 +2300,55 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
     }
   }
 }
+
+/**
+ * Tests comment pagination with a node access module enabled.
+ */
+class NodeAccessCommentPagerTestCase extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Node comment pagination',
+      'description' => 'Test access controlled nodes have the right amount of comment pages.',
+      'group' => 'Node',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp('node_access_test', 'comment');
+    node_access_rebuild();
+    $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'node test view'));
+  }
+
+  /**
+   * Tests the comment pager for nodes with multiple grants per realm.
+   */
+  public function testPageCount() {
+    // Create a node.
+    $node = $this->drupalCreateNode();
+
+    // Create 60 comments.
+    for ($i = 0; $i < 60; $i++) {
+      $comment = entity_create('comment', array(
+        'nid' => $node->nid,
+        'subject' => $this->randomName(),
+        'comment_body' => array(
+          LANGUAGE_NONE => array(
+            array('value' => $this->randomName()),
+          ),
+        ),
+      ));
+      $comment->save();
+    }
+
+    $this->drupalLogin($this->web_user);
+
+    // View the node page. With the default 50 comments per page there should
+    // be two pages (0, 1) but no third (2) page.
+    $this->drupalGet('node/' . $node->nid);
+    $this->assertText($node->title, t('Node title found.'));
+    $this->assertText(t('Comments'), t('Has a comments section.'));
+    $this->assertRaw('page=1', t('Secound page exists.'));
+    $this->assertNoRaw('page=2', t('No third page exists.'));
+  }
+}
diff --git a/core/modules/node/tests/node_access_test.module b/core/modules/node/tests/node_access_test.module
index f946573..02c3257 100644
--- a/core/modules/node/tests/node_access_test.module
+++ b/core/modules/node/tests/node_access_test.module
@@ -15,7 +15,7 @@ function node_access_test_node_grants($account, $op) {
   // First grant a grant to the author for own content.
   $grants['node_access_test_author'] = array($account->uid);
   if ($op == 'view' && user_access('node test view', $account)) {
-    $grants['node_access_test'] = array(8888);
+    $grants['node_access_test'] = array(8888, 8889);
   }
   if ($op == 'view' && $account->uid == variable_get('node_test_node_access_all_uid', 0)) {
     $grants['node_access_all'] = array(0);
@@ -38,6 +38,14 @@ function node_access_test_node_access_records($node) {
       'grant_delete' => 0,
       'priority' => 0,
     );
+    $grants[] = array(
+      'realm' => 'node_access_test',
+      'gid' => 8889,
+      'grant_view' => 1,
+      'grant_update' => 0,
+      'grant_delete' => 0,
+      'priority' => 0,
+    );
     // For the author realm, the GID is equivalent to a UID, which
     // means there are many many groups of just 1 user.
     $grants[] = array(
