mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b015efce49
https://github.com/mozilla/addon-sdk/compare/firefox27...50697e6182cb4f79f9605b7cd1d1f5084cfaf03f --HG-- rename : addon-sdk/source/data/index.html => addon-sdk/source/test/addons/addon-page/data/index.html rename : addon-sdk/source/test/favicon-helpers.js => addon-sdk/source/test/addons/places/favicon-helpers.js rename : addon-sdk/source/test/places-helper.js => addon-sdk/source/test/addons/places/places-helper.js rename : addon-sdk/source/data/test-trusted-document.html => addon-sdk/source/test/addons/symbiont/data/test-trusted-document.html rename : addon-sdk/source/data/index.html => addon-sdk/source/test/fixtures/index.html rename : addon-sdk/source/data/mofo_logo.SVG => addon-sdk/source/test/fixtures/mofo_logo.SVG rename : addon-sdk/source/data/moz_favicon.ico => addon-sdk/source/test/fixtures/moz_favicon.ico rename : addon-sdk/source/data/pagemod-css-include-file.css => addon-sdk/source/test/fixtures/pagemod-css-include-file.css rename : addon-sdk/source/data/test-content-symbiont.js => addon-sdk/source/test/fixtures/test-content-symbiont.js rename : addon-sdk/source/data/test-context-menu.js => addon-sdk/source/test/fixtures/test-context-menu.js rename : addon-sdk/source/data/test-iframe-postmessage.html => addon-sdk/source/test/fixtures/test-iframe-postmessage.html rename : addon-sdk/source/data/test-iframe.html => addon-sdk/source/test/fixtures/test-iframe.html rename : addon-sdk/source/data/test-iframe.js => addon-sdk/source/test/fixtures/test-iframe.js rename : addon-sdk/source/data/test-message-manager.js => addon-sdk/source/test/fixtures/test-message-manager.js rename : addon-sdk/source/data/test-net-url.txt => addon-sdk/source/test/fixtures/test-net-url.txt rename : addon-sdk/source/data/test-page-mod.html => addon-sdk/source/test/fixtures/test-page-mod.html rename : addon-sdk/source/data/test-page-worker.html => addon-sdk/source/test/fixtures/test-page-worker.html rename : addon-sdk/source/data/test-page-worker.js => addon-sdk/source/test/fixtures/test-page-worker.js rename : addon-sdk/source/data/test-sidebar-addon-global.html => addon-sdk/source/test/fixtures/test-sidebar-addon-global.html rename : addon-sdk/source/data/test-trusted-document.html => addon-sdk/source/test/fixtures/test-trusted-document.html rename : addon-sdk/source/data/test.html => addon-sdk/source/test/fixtures/test.html rename : addon-sdk/source/data/testLocalXhr.json => addon-sdk/source/test/fixtures/testLocalXhr.json
213 lines
6.0 KiB
JavaScript
213 lines
6.0 KiB
JavaScript
/* 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/. */
|
|
|
|
"use strict";
|
|
|
|
const { readURI, readURISync } = require("sdk/net/url");
|
|
const data = require("./fixtures");
|
|
|
|
const utf8text = "Hello, ゼロ!";
|
|
const latin1text = "Hello, ゼãƒ!";
|
|
|
|
const dataURIutf8 = "data:text/plain;charset=utf-8," + encodeURIComponent(utf8text);
|
|
const dataURIlatin1 = "data:text/plain;charset=ISO-8859-1," + escape(latin1text);
|
|
const chromeURI = "chrome://global-platform/locale/accessible.properties";
|
|
|
|
exports["test async readURI"] = function(assert, done) {
|
|
let content = "";
|
|
|
|
readURI(data.url("test-net-url.txt")).then(function(data) {
|
|
content = data;
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
done();
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
done();
|
|
})
|
|
|
|
assert.equal(content, "", "The URL content is not load yet");
|
|
}
|
|
|
|
exports["test sync readURI"] = function(assert) {
|
|
let content = "";
|
|
|
|
readURI(data.url("test-net-url.txt"), { sync: true }).then(function(data) {
|
|
content = data;
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
})
|
|
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test readURISync"] = function(assert) {
|
|
let content = readURISync(data.url("test-net-url.txt"));
|
|
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test async readURI with ISO-8859-1 charset"] = function(assert, done) {
|
|
let content = "";
|
|
|
|
readURI(data.url("test-net-url.txt"), { charset : "ISO-8859-1"}).then(function(data) {
|
|
content = data;
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
done();
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
done();
|
|
})
|
|
|
|
assert.equal(content, "", "The URL content is not load yet");
|
|
}
|
|
|
|
exports["test sync readURI with ISO-8859-1 charset"] = function(assert) {
|
|
let content = "";
|
|
|
|
readURI(data.url("test-net-url.txt"), {
|
|
sync: true,
|
|
charset: "ISO-8859-1"
|
|
}).then(function(data) {
|
|
content = data;
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
})
|
|
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test readURISync with ISO-8859-1 charset"] = function(assert) {
|
|
let content = readURISync(data.url("test-net-url.txt"), "ISO-8859-1");
|
|
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test async readURI with not existing file"] = function(assert, done) {
|
|
readURI(data.url("test-net-url-fake.txt")).then(function(data) {
|
|
assert.fail("should not resolve");
|
|
done();
|
|
}, function(reason) {
|
|
assert.ok(reason.indexOf("Failed to read:") === 0);
|
|
done();
|
|
})
|
|
}
|
|
|
|
exports["test sync readURI with not existing file"] = function(assert) {
|
|
readURI(data.url("test-net-url-fake.txt"), { sync: true }).then(function(data) {
|
|
assert.fail("should not resolve");
|
|
}, function(reason) {
|
|
assert.ok(reason.indexOf("Failed to read:") === 0);
|
|
})
|
|
}
|
|
|
|
exports["test readURISync with not existing file"] = function(assert) {
|
|
assert.throws(function() {
|
|
readURISync(data.url("test-net-url-fake.txt"));
|
|
}, /NS_ERROR_FILE_NOT_FOUND/);
|
|
}
|
|
|
|
exports["test async readURI with data URI"] = function(assert, done) {
|
|
let content = "";
|
|
|
|
readURI(dataURIutf8).then(function(data) {
|
|
content = data;
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
done();
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
done();
|
|
})
|
|
|
|
assert.equal(content, "", "The URL content is not load yet");
|
|
}
|
|
|
|
exports["test sync readURI with data URI"] = function(assert) {
|
|
let content = "";
|
|
|
|
readURI(dataURIutf8, { sync: true }).then(function(data) {
|
|
content = data;
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
})
|
|
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test readURISync with data URI"] = function(assert) {
|
|
let content = readURISync(dataURIutf8);
|
|
|
|
assert.equal(content, utf8text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test async readURI with data URI and ISO-8859-1 charset"] = function(assert, done) {
|
|
let content = "";
|
|
|
|
readURI(dataURIlatin1, { charset : "ISO-8859-1"}).then(function(data) {
|
|
content = unescape(data);
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
done();
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
done();
|
|
})
|
|
|
|
assert.equal(content, "", "The URL content is not load yet");
|
|
}
|
|
|
|
exports["test sync readURI with data URI and ISO-8859-1 charset"] = function(assert) {
|
|
let content = "";
|
|
|
|
readURI(dataURIlatin1, {
|
|
sync: true,
|
|
charset: "ISO-8859-1"
|
|
}).then(function(data) {
|
|
content = unescape(data);
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
})
|
|
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test readURISync with data URI and ISO-8859-1 charset"] = function(assert) {
|
|
let content = unescape(readURISync(dataURIlatin1, "ISO-8859-1"));
|
|
|
|
assert.equal(content, latin1text, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test readURISync with chrome URI"] = function(assert) {
|
|
let content = readURISync(chromeURI);
|
|
|
|
assert.ok(content, "The URL content is loaded properly");
|
|
}
|
|
|
|
exports["test async readURI with chrome URI"] = function(assert, done) {
|
|
let content = "";
|
|
|
|
readURI(chromeURI).then(function(data) {
|
|
content = data;
|
|
assert.equal(content, readURISync(chromeURI), "The URL content is loaded properly");
|
|
done();
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
done();
|
|
})
|
|
|
|
assert.equal(content, "", "The URL content is not load yet");
|
|
}
|
|
|
|
exports["test sync readURI with chrome URI"] = function(assert) {
|
|
let content = "";
|
|
|
|
readURI(chromeURI, { sync: true }).then(function(data) {
|
|
content = data;
|
|
}, function() {
|
|
assert.fail("should not reject");
|
|
})
|
|
|
|
assert.equal(content, readURISync(chromeURI), "The URL content is loaded properly");
|
|
}
|
|
|
|
require("test").run(exports)
|