summaryrefslogtreecommitdiffstats
path: root/rdf/tests/unit
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 /rdf/tests/unit
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 'rdf/tests/unit')
-rwxr-xr-xrdf/tests/unit/sample.rdf9
-rw-r--r--rdf/tests/unit/test_rdfredirect.js97
-rw-r--r--rdf/tests/unit/xpcshell.ini6
3 files changed, 112 insertions, 0 deletions
diff --git a/rdf/tests/unit/sample.rdf b/rdf/tests/unit/sample.rdf
new file mode 100755
index 000000000..42de8cd08
--- /dev/null
+++ b/rdf/tests/unit/sample.rdf
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+
+ <rdf:Description about="urn:mozilla:sample-data"
+ dc:title="Sample" />
+
+</rdf:RDF>
diff --git a/rdf/tests/unit/test_rdfredirect.js b/rdf/tests/unit/test_rdfredirect.js
new file mode 100644
index 000000000..40b01a49a
--- /dev/null
+++ b/rdf/tests/unit/test_rdfredirect.js
@@ -0,0 +1,97 @@
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cu = Components.utils;
+var Cr = Components.results;
+
+Cu.import("resource://testing-common/httpd.js");
+
+function getRDFService()
+{
+ return Cc["@mozilla.org/rdf/rdf-service;1"].
+ getService(Ci.nsIRDFService);
+}
+
+var server1, server2;
+
+function run_test()
+{
+ var samplefile = do_get_file('sample.rdf');
+
+ server1 = new HttpServer();
+ server1.registerPathHandler("/sample-xs.rdf", xsRedirect);
+ server1.registerPathHandler("/sample-local.rdf", localRedirect);
+ server1.registerFile('/sample.rdf', samplefile);
+ server1.start(4444);
+
+ server2 = new HttpServer();
+ server2.registerFile('/sample.rdf', samplefile);
+ server2.start(4445);
+
+ do_test_pending();
+
+ new rdfLoadObserver('http://localhost:4444/sample.rdf', true);
+ new rdfLoadObserver('http://localhost:4445/sample.rdf', true);
+ new rdfLoadObserver('http://localhost:4444/sample-xs.rdf', false);
+ new rdfLoadObserver('http://localhost:4444/sample-local.rdf', true);
+}
+
+var gPending = 0;
+
+function rdfLoadObserver(uri, shouldPass)
+{
+ this.shouldPass = shouldPass;
+ this.uri = uri;
+
+ ++gPending;
+
+ var rdfService = getRDFService();
+ this.ds = rdfService.GetDataSource(uri).
+ QueryInterface(Ci.nsIRDFXMLSink);
+ this.ds.addXMLSinkObserver(this);
+}
+
+rdfLoadObserver.prototype =
+{
+ onBeginLoad : function() { },
+ onInterrupt : function() { },
+ onResume : function() { },
+ onEndLoad : function() {
+ print("Testing results of loading " + this.uri);
+
+ var rdfs = getRDFService();
+ var res = rdfs.GetResource("urn:mozilla:sample-data");
+ var arc = rdfs.GetResource("http://purl.org/dc/elements/1.1/title");
+ var answer = this.ds.GetTarget(res, arc, true);
+ if (answer !== null) {
+ do_check_true(this.shouldPass);
+ do_check_true(answer instanceof Ci.nsIRDFLiteral);
+ do_check_eq(answer.Value, "Sample");
+ }
+ else {
+ do_check_false(this.shouldPass);
+ }
+
+ gPending -= 1;
+
+ this.ds.removeXMLSinkObserver(this);
+
+ if (gPending == 0) {
+ do_test_pending();
+ server1.stop(do_test_finished);
+ server2.stop(do_test_finished);
+ }
+ },
+ onError : function() { }
+}
+
+function xsRedirect(metadata, response)
+{
+ response.setStatusLine(metadata.httpVersion, 301, "Moved Permanently");
+ response.setHeader("Location", "http://localhost:4445/sample.rdf", false);
+}
+
+function localRedirect(metadata, response)
+{
+ response.setStatusLine(metadata.httpVersion, 301, "Moved Permanently");
+ response.setHeader("Location", "http://localhost:4444/sample.rdf", false);
+}
diff --git a/rdf/tests/unit/xpcshell.ini b/rdf/tests/unit/xpcshell.ini
new file mode 100644
index 000000000..99ab82395
--- /dev/null
+++ b/rdf/tests/unit/xpcshell.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+head =
+tail =
+support-files = sample.rdf
+
+[test_rdfredirect.js]