Bug 754178 - Expose SpecialPowers in Marionette chrome JS. r=jgriffin
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Fri, 18 May 2012 13:30:04 -0700
changeset 96625 cc0b4c5c3ac2609ba7926ef13ede6585ef263d4e
parent 96624 f4d51fab6cec21c2e51549c4b2929268781ed93f
child 96626 921706236f86b85e1df48757963ddc87a98d0cb9
push idunknown
push userunknown
push dateunknown
reviewersjgriffin
bugs754178
milestone15.0a1
Bug 754178 - Expose SpecialPowers in Marionette chrome JS. r=jgriffin
testing/marionette/client/marionette/tests/unit/test_specialpowers.py
testing/marionette/client/marionette/tests/unit/unit-tests.ini
testing/marionette/jar.mn
testing/marionette/marionette-actors.js
new file mode 100644
--- /dev/null
+++ b/testing/marionette/client/marionette/tests/unit/test_specialpowers.py
@@ -0,0 +1,16 @@
+# 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/.
+
+from marionette_test import MarionetteTestCase
+from errors import JavascriptException, MarionetteException
+
+class TestSpecialPowers(MarionetteTestCase):
+
+    def test_prefs(self):
+        self.marionette.set_context("chrome")
+        result = self.marionette.execute_script("""
+        SpecialPowers.setCharPref("testing.marionette.charpref", "blabla");
+        return SpecialPowers.getCharPref("testing.marionette.charpref")
+        """);
+        self.assertEqual(result, "blabla")
--- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini
@@ -18,13 +18,14 @@ b2g = false
 
 [test_navigation.py]
 b2g = false
 
 [test_simpletest_pass.js]
 [test_simpletest_sanity.py]
 [test_simpletest_chrome.js]
 [test_simpletest_timeout.js]
+[test_specialpowers.py]
 [test_switch_frame.py]
 b2g = false
 
 [test_window_management.py]
 b2g = false
--- a/testing/marionette/jar.mn
+++ b/testing/marionette/jar.mn
@@ -2,8 +2,17 @@ marionette.jar:
 % content marionette %content/
   content/marionette-actors.js      (marionette-actors.js)
   content/marionette-listener.js    (marionette-listener.js)
   content/marionette-elements.js    (marionette-elements.js)
   content/marionette-log-obj.js     (marionette-log-obj.js)
   content/marionette-simpletest.js  (marionette-simpletest.js)
   content/EventUtils.js  (EventUtils.js)
   content/ChromeUtils.js  (ChromeUtils.js)
+
+% content specialpowers %content/
+  content/specialpowers.js (../mochitest/specialpowers/content/specialpowers.js)
+  content/specialpowersAPI.js (../mochitest/tests/SimpleTest/specialpowersAPI.js)
+  content/SpecialPowersObserverAPI.js (../mochitest/tests/SimpleTest/SpecialPowersObserverAPI.js)
+  content/ChromePowers.js (../mochitest/tests/SimpleTest/ChromePowers.js)
+
+% resource mochikit %modules/
+  modules/MockFilePicker.jsm (../mochitest/MockFilePicker.jsm)
--- a/testing/marionette/marionette-actors.js
+++ b/testing/marionette/marionette-actors.js
@@ -419,16 +419,23 @@ MarionetteDriverActor.prototype = {
     _chromeSandbox.__namedArgs = this.curBrowser.elementManager.applyNamedArgs(args);
     _chromeSandbox.__marionetteParams = args;
     _chromeSandbox.testUtils = utils;
 
     marionette.exports.forEach(function(fn) {
       _chromeSandbox[fn] = marionette[fn].bind(marionette);
     });
 
+    loader.loadSubScript("chrome://specialpowers/content/specialpowersAPI.js",
+                         _chromeSandbox);
+    loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js",
+                         _chromeSandbox);
+    loader.loadSubScript("chrome://specialpowers/content/ChromePowers.js",
+                         _chromeSandbox);
+
     return _chromeSandbox;
   },
 
   /**
    * Executes a script in the given sandbox.
    *
    * @param Sandbox sandbox
    *        Sandbox in which the script will run