Skip to content

Instantly share code, notes, and snippets.

@illicitonion
Created November 19, 2012 14:40
Show Gist options
  • Save illicitonion/4110995 to your computer and use it in GitHub Desktop.
Save illicitonion/4110995 to your computer and use it in GitHub Desktop.
ff36 ssl patch
Index: javascript/firefox-driver/js/files.js
===================================================================
--- javascript/firefox-driver/js/files.js (revision 17832)
+++ javascript/firefox-driver/js/files.js (working copy)
@@ -31,9 +31,7 @@
var prefix = opt_prefix || '';
var suffix = opt_suffix || '';
- var tmpdir = Components.classes['@mozilla.org/file/directory_service;1'].
- getService(Components.interfaces.nsIProperties).
- get('ProfD', Components.interfaces.nsILocalFile);
+ var tmpdir = fxdriver.files.getTmpDir_();
var exists = true;
var file;
while (exists) {
@@ -48,6 +46,28 @@
};
/**
+ * Retrieves the directory to create files in. Creating the current profile
+ * directory over OS/tmp.
+ * @return {!nsILocalFile} The directory.
+ * @private
+ */
+fxdriver.files.getTmpDir_ = function() {
+ var properties = Components.classes['@mozilla.org/file/directory_service;1'].
+ getService(Components.interfaces.nsIProperties);
+ try {
+ return properties.get('ProfD', Components.interfaces.nsILocalFile);
+ } catch (ex) {
+ try {
+ return properties.get('TmpD', Components.interfaces.nsILocalFile);
+ } catch (ex) {
+ var consoleService = Components.classes['@mozilla.org/consoleservice;1']
+ .getService(Components.interfaces.nsIConsoleService);
+ consoleService.logStringMessage('Unable to get ProfD or TmpD properties!');
+ }
+ }
+};
+
+/**
* Creates a file handler for a file in the active firefox profile directory
* with the given path.
*
@@ -72,9 +92,7 @@
* @return {!nsILocalFile} The file.
*/
fxdriver.files.getLocalFile_ = function(path) {
- var file = Components.classes['@mozilla.org/file/directory_service;1'].
- getService(Components.interfaces.nsIProperties).
- get('ProfD', Components.interfaces.nsILocalFile);
+ var file = fxdriver.files.getTmpDir_();
file.initWithPath(path);
if (!file.exists()) {
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment