gabrielg-xultestrunner 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
  XULTestRunner
2
2
  =============
3
3
 
4
- This is a XUL based test runner for running the quasi-scriptaculous-unittest.js-based tests that Conflagration and WaterTower use.
4
+ This is a XUL based test runner for running the quasi-scriptaculous-unittest.js-based tests that Conflagration and WaterTower and XPCOMCore use.
5
5
 
6
6
  Yes, it is a XUL app in a RubyGem, yes I am in touch with this.
7
7
 
data/Rakefile CHANGED
@@ -11,6 +11,8 @@ begin
11
11
  s.homepage = "http://github.com/gabrielg/xultestrunner"
12
12
  s.description = "XUL based test runner for running your JS unit tests."
13
13
  s.authors = ["Gabriel Gironda"]
14
+ # FIXME - weird hack around jeweler ignoring the submoduled in xpcomcore.
15
+ s.files = (s.files + FileList["xulapp/chrome/content/vendor/**/*"]).uniq
14
16
  end
15
17
 
16
18
  application_ini_path = (Pathname(__FILE__).parent + "xulapp/application.ini").expand_path
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -1,7 +1,7 @@
1
1
  [App]
2
2
  Name=XULTestRunner
3
- Version=0.2.5
4
- BuildID=49c734f4-e677-4078-bf50-499f33b8e58f
3
+ Version=0.2.6
4
+ BuildID=f5199da3-fe6b-49ae-9911-7ddfda0ee953
5
5
  ID=XULTestRunner@conflagrationjs.org
6
6
  Vendor=Conflagration JS
7
7
 
@@ -0,0 +1,31 @@
1
+ XPCOMCore
2
+ =========
3
+
4
+ A standard library like Ruby's, only for JavaScript (with XPCOM access).
5
+
6
+ Installation
7
+ ============
8
+
9
+ Check out / submodule in / whatever the code to a place of your choosing. Then load it from an XPCOM component like so:
10
+
11
+ COMPONENTS = [];
12
+ var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
13
+ // We use the /app resource here because of yet another weird firefox issue where the /xultestrunner resource
14
+ // isn't working as the XPCOM component gets registered.
15
+ loader.loadSubScript("resource://app/chrome/content/vendor/xpcomcore/bootstrap.js");
16
+ loader.loadSubScript("resource://xpcomcore/loader.js");
17
+
18
+ Make sure that if you're registering your own component, you add it to the COMPONENTS array and build NSGetModule that way, kind of like so:
19
+
20
+ COMPONENTS.push(MYXPCOMComponent);
21
+ NSGetModule = function(compMgr, fileSpec) {
22
+ return XPCOMUtils.generateModule(COMPONENTS);
23
+ };
24
+
25
+ Then, whenever you want to make use of XPCOMCore (say, from a XUL window), load the resource in like so:
26
+
27
+ <script type="text/javascript" src="resource://xpcomcore/loader.js" />
28
+
29
+ Then you'll have access to methods such as load() and require() and whatever else is defined in Kernel.
30
+
31
+ - Gabriel Gironda
@@ -0,0 +1,7 @@
1
+ task :test do
2
+ require 'pathname'
3
+ ENV['XPCOMCORE'] = (Pathname(__FILE__).parent + "bootstrap.js").expand_path.to_s
4
+ exec("xultest", "-testDir", (Pathname(__FILE__).parent + "test/").expand_path.to_s)
5
+ end
6
+
7
+ task :default => :test
@@ -0,0 +1,108 @@
1
+ (function(backStage) {
2
+ if (typeof(COMPONENTS) == 'undefined') {
3
+ throw("Please define a COMPONENTS array before loading XPCOMCore.");
4
+ };
5
+
6
+ var requiredMinGeckoVersion = '1.9.0'; // RequiredMinGeckoVersion - Do not remove this comment.
7
+ var xpcomCoreVersion = '0.1.0'; // XPCOMCoreVersion - Do not remove this comment.
8
+
9
+ var checkGeckoVersion = function() {
10
+ var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator);
11
+ var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo);
12
+ if (versionComparator.compare(appInfo.platformVersion, requiredMinGeckoVersion) < 0) {
13
+ throw("Gecko version '" + appInfo.platformVersion + "' is unable to use XPCOMCore.");
14
+ }
15
+ };
16
+
17
+ var setupXPCOMCore = function() {
18
+ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
19
+
20
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
21
+ var resProt = ioService.getProtocolHandler("resource").QueryInterface(Components.interfaces.nsIResProtocolHandler);
22
+ // FIXME IN GENERAL - refactor all this shit code
23
+
24
+ var ourFileURIString = function() {
25
+ // FIXME - Great. All this is a dance around the fact line #289 of mozJSSubScriptLoader.cpp in mozilla 1.9.1
26
+ // thinks that the best way to delimit script files is with a fucking ASCII arrow YOU FUCKS
27
+ var thisFile = (new Error).stack.split("\n")[2].split("@")[1].split(" -> ").slice(-1)[0].split(/:[0-9]/)[0];
28
+ return thisFile;
29
+ };
30
+
31
+ var ourFileURI = function() {
32
+ return ioService.newURI(ourFileURIString(), null, null).QueryInterface(Components.interfaces.nsIURL);
33
+ };
34
+
35
+ // FIXME - hilariously non-cross-platform
36
+ var ourLibDir = function() {
37
+ var fileURI = ourFileURI();
38
+ if (fileURI.scheme == "resource") {
39
+ var thisDir = ioService.newURI(resProt.resolveURI(fileURI), null, null).QueryInterface(Components.interfaces.nsIURL).directory;
40
+ } else {
41
+ // Assumes we're a file:// URI
42
+ var thisDir = fileURI.directory;
43
+ }
44
+ return thisDir + "lib/";
45
+ };
46
+
47
+ // FIXME - hilariously non-cross-platform
48
+ var setupResourceSubstition = function() {
49
+ resProt.setSubstitution("xpcomcore", ioService.newURI("file://" + ourLibDir(), null, null));
50
+ };
51
+
52
+ setupResourceSubstition();
53
+ var libDirectory = ourLibDir();
54
+
55
+ // Private XPCOMCoreMCP method. This is the jank that finally sets up our resouce substition
56
+ // and loads Kernel methods into the given scope and .
57
+ var loadKernel = function(scope) {
58
+
59
+ // Copy properties from Kernel to the scope as getters as part of the kernel loading
60
+ // TODO - skip non-function properties
61
+ for (p in scope.Kernel) {
62
+ scope.__defineGetter__(p, function() { return scope.Kernel[p] });
63
+ }
64
+ };
65
+
66
+ // XPCOMCoreMCP is a singleton
67
+ var xpcomCoreInstance = null;
68
+ var XPCOMCoreMCP = function() {
69
+ if (xpcomCoreInstance) { return xpcomCoreInstance; }
70
+ xpcomCoreInstance = this.wrappedJSObject = this;
71
+
72
+ };
73
+
74
+ XPCOMCoreMCP.prototype = {
75
+ classDescription: "XPCOMCore Core Object",
76
+ contractID: "@conflagrationjs.org/xpcomcore/core;1",
77
+ classID: Components.ID("{f562f600-9c25-11de-8a39-0800200c9a66}"),
78
+ QueryInterface: XPCOMUtils.generateQI(),
79
+ _xpcom_categories: [{category: "JavaScript global property", entry: "XPCOMCoreMCP"}],
80
+
81
+ get version() { return new String(xpcomCoreVersion); },
82
+ get libRoot() { return new String(libDirectory); },
83
+
84
+ loadInto: function(loadScope) {
85
+ if (!loadScope || loadScope.XPCOMCoreLoaded) {
86
+ return false;
87
+ } else {
88
+ loadKernel(loadScope);
89
+ loadScope.XPCOMCoreLoaded = true;
90
+ return true;
91
+ }
92
+ }
93
+ };
94
+
95
+ backStage.XPCOMCoreMCP = XPCOMCoreMCP;
96
+ // Make sure we actually register the component or everything blows up
97
+ COMPONENTS.push(XPCOMCoreMCP);
98
+
99
+ };
100
+
101
+ try {
102
+ checkGeckoVersion();
103
+ setupXPCOMCore();
104
+ } catch (e) {
105
+ dump("Couldn't register XPCOMCore: " + e + "\n");
106
+ }
107
+
108
+ })(this);
@@ -0,0 +1,77 @@
1
+ // Convenience shortcuts
2
+ const Cc = Components.classes;
3
+ const Ci = Components.interfaces;
4
+ const Cr = Components.results;
5
+ const Cu = Components.utils;
6
+
7
+ // Taking some inspiration from Ruby here...
8
+ const $LOAD_PATH = [XPCOMCore.libRoot];
9
+ const $LOADED_FEATURES = ["kernel.js"];
10
+
11
+ const $FILE = function() {
12
+ var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
13
+ var thisFile = (new Error).stack.split("\n")[2].split("@")[1].split(" -> ").slice(-1)[0].split(/:[0-9]/)[0];
14
+ var thisFileURI = ioService.newURI(thisFile, null, null);
15
+
16
+ if (thisFileURI.scheme == "resource") {
17
+ var resProt = ioService.getProtocolHandler("resource").QueryInterface(Components.interfaces.nsIResProtocolHandler);
18
+ return ioService.newURI(resProt.resolveURI(thisFileURI), null, null).QueryInterface(Ci.nsIURL).path;
19
+ } else if (thisFileURI.scheme == "file") {
20
+ return thisFileURI.QueryInterface(Ci.nsIURL).path;
21
+ } else {
22
+ // FIXME - throw an appropriate exception here.
23
+ return null;
24
+ }
25
+ }
26
+
27
+ // FIXME - better exceptions.
28
+ const LoadError = {name: "LoadError", message: "Could not load file"};
29
+
30
+ const Kernel = {
31
+
32
+ print: function(str) {
33
+ dump(str);
34
+ },
35
+
36
+ puts: function(str) {
37
+ print(str + "\n");
38
+ },
39
+
40
+ load: function(featurePath) {
41
+ var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
42
+ var foundFile = null;
43
+ // FIXME - so this is kinda shitty. We have an empty entry here so we default to just trying to load
44
+ // from an absolute path
45
+ var loadPath = $LOAD_PATH.concat([""]);
46
+ var loadPathLength = loadPath.length;
47
+ // FIXME - mozilla bug here. if i use foreach on array it ignores the granted security privileges
48
+ for (var i = 0; i < loadPathLength; i++) {
49
+ var potentialFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
50
+ potentialFile.initWithPath(loadPath[i] + "/" + featurePath);
51
+ if (potentialFile.exists()) {
52
+ foundFile = potentialFile;
53
+ break;
54
+ }
55
+ };
56
+ if (foundFile) {
57
+ foundFile.normalize();
58
+ loader.loadSubScript("file://" + encodeURI(foundFile.path));
59
+ $LOADED_FEATURES.push(featurePath)
60
+ } else {
61
+ throw(LoadError);
62
+ }
63
+ },
64
+
65
+ require: function(feature) {
66
+ var jsFeature = feature + ".js";
67
+ if ($LOADED_FEATURES.indexOf(jsFeature) == -1) {
68
+ load(jsFeature);
69
+ return true;
70
+ } else {
71
+ return false;
72
+ }
73
+ }
74
+ }
75
+
76
+ // FIXME - i just puked in my mouth a little.
77
+ for (p in Kernel) { eval('var ' + p + ' = Kernel[p];'); }
@@ -0,0 +1,16 @@
1
+ // FIXME - If we're still backstage, load differently. Need a better way to check for being backstage.
2
+ // FIXME - wow, this is all so seedy.
3
+ var _coreObj = null;
4
+ if (this.toString() == "[object BackstagePass]" && typeof(XPCOMCore) == 'undefined') {
5
+ _coreObj = new this.XPCOMCoreMCP();
6
+ } else if (this.XPCOMCoreMCP && typeof(XPCOMCore) == 'undefined') {
7
+ var privileges = 'UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite ' +
8
+ 'UniversalPreferencesRead UniversalPreferencesWrite CapabilityPreferencesAccess UniversalFileRead';
9
+ netscape.security.PrivilegeManager.enablePrivilege(privileges);
10
+ _coreObj = this.XPCOMCoreMCP.wrappedJSObject;
11
+ };
12
+
13
+ const XPCOMCore = _coreObj;
14
+
15
+ var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
16
+ loader.loadSubScript("resource://xpcomcore/kernel.js");
@@ -0,0 +1,7 @@
1
+ XULTestCase.create("Kernel Test", function(setup, teardown, test) {
2
+
3
+ test("it would be swell if i wrote a test", function(){
4
+ this.assert(false);
5
+ });
6
+
7
+ });
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xultestrunner}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gabriel Gironda"]
12
- s.date = %q{2009-09-08}
12
+ s.date = %q{2009-09-10}
13
13
  s.default_executable = %q{xultest}
14
14
  s.description = %q{XUL based test runner for running your JS unit tests.}
15
15
  s.email = %q{contact@gironda.org}
@@ -38,6 +38,12 @@ Gem::Specification.new do |s|
38
38
  "xulapp/chrome/content/vendor/scriptaculous/LICENSE",
39
39
  "xulapp/chrome/content/vendor/scriptaculous/test.css",
40
40
  "xulapp/chrome/content/vendor/scriptaculous/unittest.js",
41
+ "xulapp/chrome/content/vendor/xpcomcore/README",
42
+ "xulapp/chrome/content/vendor/xpcomcore/Rakefile",
43
+ "xulapp/chrome/content/vendor/xpcomcore/bootstrap.js",
44
+ "xulapp/chrome/content/vendor/xpcomcore/lib/kernel.js",
45
+ "xulapp/chrome/content/vendor/xpcomcore/lib/loader.js",
46
+ "xulapp/chrome/content/vendor/xpcomcore/test/kernel_test.js",
41
47
  "xulapp/components/bootstrap.js",
42
48
  "xulapp/defaults/preferences/prefs.js",
43
49
  "xultestrunner.gemspec"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gabrielg-xultestrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Gironda
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-08 00:00:00 -07:00
12
+ date: 2009-09-10 00:00:00 -07:00
13
13
  default_executable: xultest
14
14
  dependencies: []
15
15
 
@@ -42,11 +42,18 @@ files:
42
42
  - xulapp/chrome/content/vendor/scriptaculous/LICENSE
43
43
  - xulapp/chrome/content/vendor/scriptaculous/test.css
44
44
  - xulapp/chrome/content/vendor/scriptaculous/unittest.js
45
+ - xulapp/chrome/content/vendor/xpcomcore/README
46
+ - xulapp/chrome/content/vendor/xpcomcore/Rakefile
47
+ - xulapp/chrome/content/vendor/xpcomcore/bootstrap.js
48
+ - xulapp/chrome/content/vendor/xpcomcore/lib/kernel.js
49
+ - xulapp/chrome/content/vendor/xpcomcore/lib/loader.js
50
+ - xulapp/chrome/content/vendor/xpcomcore/test/kernel_test.js
45
51
  - xulapp/components/bootstrap.js
46
52
  - xulapp/defaults/preferences/prefs.js
47
53
  - xultestrunner.gemspec
48
54
  has_rdoc: false
49
55
  homepage: http://github.com/gabrielg/xultestrunner
56
+ licenses:
50
57
  post_install_message:
51
58
  rdoc_options:
52
59
  - --charset=UTF-8
@@ -67,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
74
  requirements: []
68
75
 
69
76
  rubyforge_project:
70
- rubygems_version: 1.2.0
77
+ rubygems_version: 1.3.5
71
78
  signing_key:
72
79
  specification_version: 3
73
80
  summary: XUL based test runner for running your JS unit tests.