summaryrefslogtreecommitdiffstats
path: root/dom/xslt/tests/buster/buster-files.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 /dom/xslt/tests/buster/buster-files.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 'dom/xslt/tests/buster/buster-files.js')
-rw-r--r--dom/xslt/tests/buster/buster-files.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/dom/xslt/tests/buster/buster-files.js b/dom/xslt/tests/buster/buster-files.js
new file mode 100644
index 000000000..cbdb8bdd2
--- /dev/null
+++ b/dom/xslt/tests/buster/buster-files.js
@@ -0,0 +1,81 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* 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/. */
+
+const kFileOutStreamCID = "@mozilla.org/network/file-output-stream;1";
+const nsIFileOutputStream = Components.interfaces.nsIFileOutputStream;
+
+var cmdFileController =
+{
+ supportsCommand: function(aCommand)
+ {
+ switch(aCommand) {
+ case 'cmd_fl_save':
+ case 'cmd_fl_import':
+ return true;
+ default:
+ }
+ return false;
+ },
+ isCommandEnabled: function(aCommand)
+ {
+ return this.supportsCommand(aCommand);
+ },
+ doCommand: function(aCommand)
+ {
+ switch(aCommand) {
+ case 'cmd_fl_save':
+ var sink = new Object;
+ sink.write = function(aContent, aCount)
+ {
+ // replace NC:succ with NC:orig_succ,
+ // so the rdf stuff differs
+ var content = aContent.replace(/NC:succ/g,"NC:orig_succ");
+ content = content.replace(/NC:failCount/g,"NC:orig_failCount");
+ this.mSink.write(content, content.length);
+ return aCount;
+ };
+ var fp = doCreateRDFFP('Xalan results',
+ nsIFilePicker.modeSave);
+ var res = fp.show();
+
+ if (res == nsIFilePicker.returnOK ||
+ res == nsIFilePicker.returnReplace) {
+ var serial = doCreate(kRDFXMLSerializerID,
+ nsIRDFXMLSerializer);
+ serial.init(view.mResultDS);
+ serial.QueryInterface(nsIRDFXMLSource);
+ var fl = fp.file;
+ var fstream = doCreate(kFileOutStreamCID,
+ nsIFileOutputStream);
+ fstream.init(fl, 26, 420, 0);
+ sink.mSink = fstream;
+ serial.Serialize(sink);
+ }
+ break;
+ case 'cmd_fl_import':
+ var fp = doCreateRDFFP('Previous Xalan results',
+ nsIFilePicker.modeLoad);
+ var res = fp.show();
+
+ if (res == nsIFilePicker.returnOK) {
+ var fl = fp.file;
+ if (view.mPreviousResultDS) {
+ view.database.RemoveDataSource(view.mPreviousResultDS);
+ view.mPreviousResultDS = null;
+ }
+ view.mPreviousResultDS = kRDFSvc.GetDataSource(fp.fileURL.spec);
+ view.database.AddDataSource(view.mPreviousResultDS);
+ }
+
+ document.getElementById('obs_orig_success')
+ .setAttribute('hidden','false');
+ break;
+ default:
+ alert('Unknown Command'+aCommand);
+ }
+ }
+};
+
+registerController(cmdFileController);