summaryrefslogtreecommitdiffstats
path: root/b2g/components/test/mochitest/screenshot_helper.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /b2g/components/test/mochitest/screenshot_helper.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'b2g/components/test/mochitest/screenshot_helper.js')
-rw-r--r--b2g/components/test/mochitest/screenshot_helper.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/b2g/components/test/mochitest/screenshot_helper.js b/b2g/components/test/mochitest/screenshot_helper.js
new file mode 100644
index 000000000..0320a14c1
--- /dev/null
+++ b/b2g/components/test/mochitest/screenshot_helper.js
@@ -0,0 +1,40 @@
+var Cu = Components.utils;
+var Ci = Components.interfaces;
+
+Cu.importGlobalProperties(['File']);
+
+const { Services } = Cu.import("resource://gre/modules/Services.jsm");
+
+// Load a duplicated copy of the jsm to prevent messing with the currently running one
+var scope = {};
+Services.scriptloader.loadSubScript("resource://gre/modules/Screenshot.jsm", scope);
+const { Screenshot } = scope;
+
+var index = -1;
+function next() {
+ index++;
+ if (index >= steps.length) {
+ assert.ok(false, "Shouldn't get here!");
+ return;
+ }
+ try {
+ steps[index]();
+ } catch(ex) {
+ assert.ok(false, "Caught exception: " + ex);
+ }
+}
+
+var steps = [
+ function getScreenshot() {
+ let screenshot = Screenshot.get();
+ assert.ok(screenshot instanceof File,
+ "Screenshot.get() returns a File");
+ next();
+ },
+
+ function endOfTest() {
+ sendAsyncMessage("finish");
+ }
+];
+
+next();