diff --git a/layout/base/tests/marionette/manifest.ini b/layout/base/tests/marionette/manifest.ini
new file mode 100644
index 00000000000..caf0e5943ab
--- /dev/null
+++ b/layout/base/tests/marionette/manifest.ini
@@ -0,0 +1,15 @@
+[DEFAULT]
+; true if the test requires an emulator, otherwise false
+qemu = false
+
+; true if the test is compatible with the browser, otherwise false
+browser = true
+
+; true if the test is compatible with b2g, otherwise false
+b2g = true
+
+; true if the test should be skipped
+skip = false
+
+[test_touchcaret.py]
+b2g = false ; Bug 1020261
diff --git a/layout/base/tests/marionette/test_touchcaret.py b/layout/base/tests/marionette/test_touchcaret.py
new file mode 100644
index 00000000000..2525f8b3e97
--- /dev/null
+++ b/layout/base/tests/marionette/test_touchcaret.py
@@ -0,0 +1,339 @@
+# -*- coding: utf-8 -*-
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import string
+
+from by import By
+from marionette import Actions
+from marionette_test import MarionetteTestCase
+
+
+class TouchCaretTest(MarionetteTestCase):
+ _input_selector = (By.ID, 'input')
+ _textarea_selector = (By.ID, 'textarea')
+ _contenteditable_selector = (By.ID, 'contenteditable')
+
+ def setUp(self):
+ # Code to execute before a tests are run.
+ MarionetteTestCase.setUp(self)
+ self.actions = Actions(self.marionette)
+
+ def openTestHtml(self, enabled=True):
+ '''Open html for testing and locate elements, and enable/disable touch
+ caret.'''
+ self.marionette.execute_script(
+ 'SpecialPowers.setBoolPref("touchcaret.enabled", %s);' %
+ ('true' if enabled else 'false'))
+
+ test_html = self.marionette.absolute_url('test_touchcaret.html')
+ self.marionette.navigate(test_html)
+
+ self._input = self.marionette.find_element(*self._input_selector)
+ self._textarea = self.marionette.find_element(*self._textarea_selector)
+ self._contenteditable = self.marionette.find_element(*self._contenteditable_selector)
+
+ def is_input_or_textarea(self, element):
+ '''Return True if element is either or