diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info
index 7b139ba..0866f60 100644
--- a/modules/simpletest/simpletest.info
+++ b/modules/simpletest/simpletest.info
@@ -14,6 +14,7 @@ files[] = tests/batch.test
 files[] = tests/bootstrap.test
 files[] = tests/cache.test
 files[] = tests/common.test
+files[] = tests/custom_theme_boot_test.test
 files[] = tests/database_test.test
 files[] = tests/entity_crud.test
 files[] = tests/entity_crud_hook_test.test
diff --git a/modules/simpletest/tests/custom_theme_boot_test.info b/modules/simpletest/tests/custom_theme_boot_test.info
new file mode 100644
index 0000000..3b1d2dd
--- /dev/null
+++ b/modules/simpletest/tests/custom_theme_boot_test.info
@@ -0,0 +1,6 @@
+name = Custom theme boot tests
+description = A support module for custom theme hook boot testing.
+core = 7.x
+package = Testing
+version = VERSION
+hidden = TRUE
diff --git a/modules/simpletest/tests/custom_theme_boot_test.module b/modules/simpletest/tests/custom_theme_boot_test.module
new file mode 100644
index 0000000..d89402e
--- /dev/null
+++ b/modules/simpletest/tests/custom_theme_boot_test.module
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @file
+ * Helper module for the custom theme boot tests.
+ */
+
+/**
+ * Implements hook_custom_theme().
+ */
+function custom_theme_boot_test_custom_theme() {
+  if (arg(0) == 'node' && is_numeric(arg(1))) {
+    // This triggers a node load - which again could trigger a whole bunch of
+    // theme related stuff e.g. by triggering token replacement in fields. If
+    // the theme handling isn't right this will lead to a broken theme registry
+    // and / or the wrong theme load.
+    $node = node_load(arg(1));
+    if ($node->type == 'page') {
+      return 'garland';
+    }
+    elseif ($node->type == 'article') {
+      return 'seven';
+    }
+  }
+}
+
+/**
+ * Implements hook_entity_load().
+ */
+function custom_theme_boot_test_entity_load($entities, $type) {
+  if ($type == 'node') {
+    foreach ($entities as $entity) {
+      // This is going to initialize the theme and break everything if not
+      // properly handled.
+      $entity->foo = l(t('foo'), '');
+    }
+  }
+}
diff --git a/modules/simpletest/tests/custom_theme_boot_test.test b/modules/simpletest/tests/custom_theme_boot_test.test
new file mode 100644
index 0000000..67f1804
--- /dev/null
+++ b/modules/simpletest/tests/custom_theme_boot_test.test
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @file
+ * Helper module for the custom theme boot tests.
+ */
+
+/**
+ * Tests for custom theme boot behaviour.
+ */
+class CustomThemeBootTestCase extends NodeWebTestCase {
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Custom theme boot tests',
+      'description' => 'Test that triggering custom theme on boot wont compromise the theme registry.',
+      'group' => 'Theme',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp('custom_theme_boot_test');
+    // Create and login admin user.
+    $this->admin_user = $this->drupalCreateUser(array(
+      'access administration pages',
+      'administer site configuration',
+      'administer themes',
+    ));
+  }
+
+  /**
+   * Create four nodes and ensure they're loaded correctly.
+   */
+  public function testNodeMultipleLoad() {
+    // Create nodes to fetch.
+    $node1 = $this->drupalCreateNode(array(
+      'type' => 'article',
+      'promote' => 1,
+    ));
+    $node2 = $this->drupalCreateNode(array(
+      'type' => 'page',
+      'promote' => 1,
+    ));
+    $this->drupalLogin($this->admin_user);
+    $this->drupalGet('admin/appearance');
+
+    // Enable Garland theme.
+    $this->clickLink('Enable');
+    // Enable Seven theme.
+    $this->clickLink('Enable');
+
+    // Clear all caches.
+    cache_clear_all();
+
+    // Fetch the node. This triggers hook_entity_load(), which is implemented by
+    // custom_theme_boot_test.module. The implementation calls l() which again
+    // end's up loading the theme.
+    $this->drupalGet('node/' . $node1->nid);
+    $this->assertText('seven');
+    $this->assertNoText('garland');
+    $this->assertNoText('bartik');
+
+    $this->drupalGet('node/' . $node2->nid);
+    $this->assertText('garland');
+    $this->assertNoText('seven');
+    $this->assertNoText('bartik');
+  }
+}
