Skip to content

Commit

Permalink
Merge branch 'master' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold committed Jan 30, 2012
2 parents e98bfa2 + dbb7d2b commit 410d9ab
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 69 deletions.
2 changes: 1 addition & 1 deletion extension/components/scriptish.js
Expand Up @@ -6,7 +6,7 @@ const Cu = Components.utils;
Cu.import("resource://scriptish/constants.js");
Cu.import("resource://scriptish/addonprovider.js");

lazyImport(this, "resource://scriptish/logging.js", ["Scriptish_logError", "Scriptish_logScriptError", "Scriptish_log"]);
lazyImport(this, "resource://scriptish/logging.js", ["Scriptish_logError", "Scriptish_log"]);
lazyImport(this, "resource://scriptish/prefmanager.js", ["Scriptish_prefRoot"]);
lazyImport(this, "resource://scriptish/scriptish.js", ["Scriptish"]);
lazyImport(this, "resource://scriptish/manager.js", ["Scriptish_manager"]);
Expand Down
6 changes: 0 additions & 6 deletions extension/content/tests/testScriptishLogger.js
Expand Up @@ -112,7 +112,6 @@ asyncTest("null char removed", 1, function() {
asyncTest("logScriptError: js error", 9, function() {
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[baz] Error: foo");
equal(message.sourceName, "chrome://scriptish/content/tests/testScriptishLogger.js");
Expand All @@ -128,7 +127,6 @@ asyncTest("logScriptError: js error", 9, function() {
asyncTest("logScriptError: nsIScriptError", 9, function() {
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[baz] foo");
equal(message.sourceName, "source");
Expand All @@ -146,7 +144,6 @@ asyncTest("logScriptError: nsIScriptError", 9, function() {
asyncTest("logScriptError: nsIScriptError; omit id", 9, function() {
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[Scriptish] foo");
equal(message.sourceName, "source");
Expand All @@ -165,7 +162,6 @@ asyncTest("test nsIScriptError; omit optionals", function() {
expect(9);
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[Scriptish] foo");
equal(message.sourceName, "[user.js]");
Expand All @@ -184,7 +180,6 @@ asyncTest("test nsIException", function() {
expect(9);
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[baz] foo");
equal(message.sourceName, "chrome://scriptish/content/tests/testScriptishLogger.js");
Expand All @@ -202,7 +197,6 @@ asyncTest("test TypeError", function() {
expect(9);
runListener(function(message) {
ok(message instanceof Ci.nsIScriptError);
ok(message instanceof Ci.nsIScriptError2);

equal(message.errorMessage, "[baz] TypeError: f is undefined");
equal(message.sourceName, "chrome://scriptish/content/tests/testScriptishLogger.js");
Expand Down
4 changes: 2 additions & 2 deletions extension/install.rdf
Expand Up @@ -6,7 +6,7 @@
<em:id>scriptish@erikvold.com</em:id>
<em:name>Scriptish</em:name>
<em:description>A Script Extension Manager for Firefox</em:description>
<em:version>0.1.6</em:version>
<em:version>0.1.7</em:version>
<em:aboutURL>chrome://scriptish/content/aboutStub.xul</em:aboutURL>
<em:homepageURL>http://scriptish.org</em:homepageURL>
<em:optionsURL>chrome://scriptish/content/options.xul</em:optionsURL>
Expand Down Expand Up @@ -72,7 +72,7 @@
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1</em:minVersion>
<em:maxVersion>2.7.*</em:maxVersion>
<em:maxVersion>2.8.*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Fennec -->
Expand Down
2 changes: 2 additions & 0 deletions extension/modules/addonprovider.js
Expand Up @@ -136,6 +136,7 @@ AddonManagerPrivate.registerProvider({
getAddonByID: function(aId, aCallback) {
aCallback(Scriptish_config.getScriptById(aId));
},

getAddonsByTypes: function(aTypes, aCallback) {
if (aTypes && aTypes.indexOf("userscript") < 0) {
aCallback([]);
Expand All @@ -158,6 +159,7 @@ AddonManagerPrivate.registerProvider({
}
}
}, types);

[
"scriptish-script-installed",
"scriptish-script-edit-enabling",
Expand Down
3 changes: 1 addition & 2 deletions extension/modules/constants.js
Expand Up @@ -33,8 +33,7 @@ var Instances = {
get fp() Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker),
get lf() Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile),
get process() Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess),
get se() Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError)
.QueryInterface(Ci.nsIScriptError2),
get se() Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError),
get ss() Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString),
get suc() Cc["@mozilla.org/intl/scriptableunicodeconverter"]
Expand Down
2 changes: 1 addition & 1 deletion extension/modules/logging.js
Expand Up @@ -50,7 +50,7 @@ function Scriptish_logScriptError(aError, aWindow, aFileURL, aId) {
var category = "scriptish userscript error";

// get what we can
if ((aError instanceof Ci.nsIScriptError) || (aError instanceof Ci.nsIScriptError2)) {
if (aError instanceof Ci.nsIScriptError) {
var {errorMessage, sourceName, sourceLine, lineNumber, columnNumber, flags, category} = aError;
}
else if (aError instanceof Ci.nsIException) {
Expand Down
33 changes: 23 additions & 10 deletions extension/modules/script/script.js
Expand Up @@ -851,6 +851,19 @@ Script.prototype = {
}
};

Script.prototype.addScreenShot = function(aURL, aThumbURL) {
if (!AddonManagerPrivate.AddonScreenshot) return;

var ss = new AddonManagerPrivate.AddonScreenshot(aURL);

if (aThumbURL) {
ss.thumbnailURL = aThumbURL;
}

this._screenshots.push(ss);
return;
}

Script.parseVersion = function Script_parseVersion(aSrc) {
var parsed = Scriptish_parser(aSrc);
if (parsed.version) return parsed.version.pop();
Expand Down Expand Up @@ -1005,14 +1018,15 @@ Script.parse = function Script_parse(aConfig, aSource, aURI, aUpdateScript) {
script._matches.push(new MatchPattern(value));
continue;
case 'screenshot':
if (!AddonManagerPrivate.AddonScreenshot) continue;
var splitValue = value.match(valueSplitter);

// if there is a thumb url provided
if (splitValue) {
script._screenshots.push(new AddonManagerPrivate.AddonScreenshot(
splitValue[1], splitValue[2]));
} else {
script._screenshots.push(new AddonManagerPrivate.AddonScreenshot(
value));
script.addScreenShot(splitValue[1], splitValue[2]);
}
// no thumb url is provided
else {
script.addScreenShot(value);
}
continue;
case "defaulticon":
Expand Down Expand Up @@ -1168,8 +1182,7 @@ Script.loadFromJSON = function(aConfig, aSkeleton) {
script._resources.push(scriptResource);
});
aSkeleton.screenshots.forEach(function(i) {
script._screenshots.push(new AddonManagerPrivate.AddonScreenshot(
i.url, i.thumbnailURL));
script.addScreenShot(i.url, i.thumbnailURL);
});

script.id = aSkeleton.id;
Expand Down Expand Up @@ -1283,8 +1296,8 @@ Script.loadFromXML = function(aConfig, aNode) {
var thumb = "";
if (childNode.hasAttribute("thumb"))
thumb = childNode.getAttribute("thumb");
script._screenshots.push(new AddonManagerPrivate.AddonScreenshot(
childNode.firstChild.nodeValue.trim(), thumb));

script.addScreenShot(childNode.firstChild.nodeValue.trim(), thumb);
break;
case "Noframes":
script["_" + childNode.nodeName.toLowerCase()] = true;
Expand Down
6 changes: 5 additions & 1 deletion extension/modules/utils/Scriptish_injectScripts.js
Expand Up @@ -50,7 +50,11 @@ function Scriptish_injectScripts(options) {
// Need to keep a valid reference to |script| around so that GM_log
// and the delay code (and probably other consumer work).
let script = scripts[i];
let sandbox = new Cu.Sandbox(safeWin);
let sandbox = new Cu.Sandbox(safeWin, {
sandboxName: script.fileURL,
//sandboxPrototype: safeWin,
wantXrays: true
});

// hack XPathResult since that is so commonly used
sandbox.XPathResult = XPATH_RESULT;
Expand Down
104 changes: 68 additions & 36 deletions extension/modules/utils/Scriptish_openInEditor.js
@@ -1,3 +1,5 @@
"use strict";

var EXPORTED_SYMBOLS = ["Scriptish_openInEditor"];

const Cu = Components.utils;
Expand All @@ -16,42 +18,7 @@ function Scriptish_openInEditor(script, parentWindow) {

try {
if ("Scratchpad" == editor) {
let spWin = (parentWindow.Scratchpad
|| Services.wm.getMostRecentWindow("navigator:browser").Scratchpad)
.openScratchpad();
spWin.addEventListener("load", function spWinLoaded() {
spWin.removeEventListener("load", spWinLoaded, false);
spWin.document.title = spWin.Scratchpad.filename = file.path;

// Open the user script in Scratchpad
// NOTE: Resetting the "undo/redo" state on our own until Scratchpad
// handles it. We want to ensure user scripts don't get screwed up.
// See: https://bug684546.bugzilla.mozilla.org/
spWin.Scratchpad.importFromFile(file, false, function() {
let spEditor = spWin.Scratchpad.editor;

// For the Orion editor...
if (spEditor && spEditor._undoStack && spEditor._undoStack.reset) {
spEditor._undoStack.reset();
return;
}

// If not using Orion, pick out the proper editor
// Scratchpad in FF6 still uses 'textbox'
if (spEditor && spEditor._editor)
spEditor = spEditor._editor;
else if (spWin.Scratchpad.textbox)
spEditor = spWin.Scratchpad.textbox.editor;

if (spEditor
&& spEditor.resetModificationCount
&& spEditor.transactionManager
&& spEditor.transactionManager.clear) {
spEditor.resetModificationCount();
spEditor.transactionManager.clear();
}
});
}, false);
openScriptInScratchpad(script, parentWindow, file);
}
else {
Scriptish_launchApplicationWithDoc(editor, file);
Expand All @@ -64,3 +31,68 @@ function Scriptish_openInEditor(script, parentWindow) {
throw e;
}
}

function openScriptInScratchpad(script, parentWindow, file) {
let spWin = (parentWindow.Scratchpad
|| Services.wm.getMostRecentWindow("navigator:browser").Scratchpad)
.openScratchpad();

spWin.addEventListener("load", function spWinLoaded() {
spWin.removeEventListener("load", spWinLoaded, false);

let Scratchpad = spWin.Scratchpad;
setFilenameForScratchpadWindow(spWin, file);

if (Scratchpad.addObserver) {
Scratchpad.addObserver({"onReady": importFileForScratchpad.bind(null, spWin, file)});
}
else {
importFileForScratchpad(spWin, file);
}
}, false);
}

function setFilenameForScratchpadWindow(spWin, file) {
let Scratchpad = spWin.Scratchpad;

// Set the filename
if (Scratchpad.setFilename) {
Scratchpad.setFilename(file.path);
}
else {
spWin.document.title = Scratchpad.filename = file.path;
}
}

function importFileForScratchpad(spWin, file) {
let Scratchpad = spWin.Scratchpad;

// Open the user script in Scratchpad
// NOTE: Resetting the "undo/redo" state on our own until Scratchpad
// handles it. We want to ensure user scripts don't get screwed up.
// See: https://bug684546.bugzilla.mozilla.org/
Scratchpad.importFromFile(file, false, function() {
let spEditor = Scratchpad.editor;

// For the Orion editor...
if (spEditor && spEditor._undoStack && spEditor._undoStack.reset) {
spEditor._undoStack.reset();
return;
}

// If not using Orion, pick out the proper editor
// Scratchpad in FF6 still uses 'textbox'
if (spEditor && spEditor._editor)
spEditor = spEditor._editor;
else if (Scratchpad.textbox)
spEditor = Scratchpad.textbox.editor;

if (spEditor
&& spEditor.resetModificationCount
&& spEditor.transactionManager
&& spEditor.transactionManager.clear) {
spEditor.resetModificationCount();
spEditor.transactionManager.clear();
}
});
}
20 changes: 10 additions & 10 deletions update.rdf
Expand Up @@ -6,39 +6,39 @@
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>0.1.6</em:version>
<em:version>0.1.7</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>11.*</em:maxVersion>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.6.xpi</em:updateLink>
<em:updateHash>sha1:c526c8377988e1d6e3e48fe2dff6d3574d037ff8</em:updateHash>
<em:maxVersion>12.0a1</em:maxVersion>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.7.xpi</em:updateLink>
<em:updateHash>sha1:1f098ee6a55778e00f057826d39b6fabecd0b8d4</em:updateHash>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1</em:minVersion>
<em:maxVersion>2.7.*</em:maxVersion>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.6.xpi</em:updateLink>
<em:updateHash>sha1:c526c8377988e1d6e3e48fe2dff6d3574d037ff8</em:updateHash>
<em:maxVersion>2.8.*</em:maxVersion>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.7.xpi</em:updateLink>
<em:updateHash>sha1:1f098ee6a55778e00f057826d39b6fabecd0b8d4</em:updateHash>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>10.*</em:maxVersion>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.6.xpi</em:updateLink>
<em:updateHash>sha1:c526c8377988e1d6e3e48fe2dff6d3574d037ff8</em:updateHash>
<em:updateLink>http://github.com/downloads/scriptish/scriptish/scriptish-0.1.7.xpi</em:updateLink>
<em:updateHash>sha1:1f098ee6a55778e00f057826d39b6fabecd0b8d4</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>

<em:signature>MIGTMA0GCSqGSIb3DQEBDQUAA4GBAJZhVqf5WIxVW8MTdm08ToHGPbXMegI6hGmhDyryy28fozh1ZvXYl5SN0/U9c7sVbgxwaMqEHG01Y82sbDZu0REE3kXXWjlRJSMJFIz4IXJ8nTxwI+6qnCgNzVKxMoVEs4x7uGH4ETQD/X3PgTEAT+nC3+KvdzPqntyMgAzz67CD</em:signature>
<em:signature>MIGTMA0GCSqGSIb3DQEBDQUAA4GBAFxIbXsnLRKFaXW4ebxmIM7rl1dVY1LLIYiygy1LAk50d71NRTh0Sk02zsykZ+/sPIxwaK4giAO/kOQxgkUGlFGk4itCGyhaHr0lAwCVoAL8O+BewwFB48hxFZvu+QRq1QTlPcxHT7RU+bZWYtxGOJhlET5bz68jczYMcDCeDj9w</em:signature>
</RDF:Description>
</RDF:RDF>

0 comments on commit 410d9ab

Please sign in to comment.