mirror of https://github.com/vitalif/phantomjs
parent
7bcb9a8725
commit
7e8986cd3e
|
@ -1,48 +0,0 @@
|
||||||
describe("WebPage CJK support", function () {
|
|
||||||
var texts = [
|
|
||||||
new Text("Shift_JIS", "g3SDQIOTg2eDgA==", "ファントム")
|
|
||||||
, new Text("EUC-JP", "pdWloaXzpcil4A0K", "ファントム")
|
|
||||||
, new Text("ISO-2022-JP", "GyRCJVUlISVzJUglYBsoQg0K", "ファントム")
|
|
||||||
, new Text("Big5", "pNu2SA0K", "幻象")
|
|
||||||
, new Text("GBK", "u8PP8w0K", "幻象")
|
|
||||||
, new Text("EUC-KR", "yK+/tQ==", "환영")
|
|
||||||
];
|
|
||||||
|
|
||||||
texts.forEach(function (t) {
|
|
||||||
it(t.codec, function() {
|
|
||||||
var decodedText = -1;
|
|
||||||
var page = new WebPage();
|
|
||||||
|
|
||||||
page.open(t.dataUrl(), function(status) {
|
|
||||||
decodedText = page.evaluate(function() {
|
|
||||||
return document.getElementsByTagName("pre")[0].innerText;
|
|
||||||
});
|
|
||||||
page.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
waitsFor(function () {
|
|
||||||
return -1 !== decodedText;
|
|
||||||
}, "Text not decoded within three seconds", 3000);
|
|
||||||
|
|
||||||
runs(function () {
|
|
||||||
expect(t.check(decodedText)).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function Text(codec, base64, reference) {
|
|
||||||
this.codec = codec;
|
|
||||||
this.base64 = base64;
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
Text.prototype.dataUrl = function () {
|
|
||||||
return "data:text/plain;charset=" + this.codec + ";base64," + this.base64;
|
|
||||||
};
|
|
||||||
|
|
||||||
Text.prototype.check = function (decodedText) {
|
|
||||||
return decodedText.match("^" + this.reference) == this.reference;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// vim:ts=4:sw=4:sts=4:et:
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
var assert = require('../../assert');
|
||||||
|
var webpage = require('webpage');
|
||||||
|
|
||||||
|
function Text(codec, base64, reference) {
|
||||||
|
this.codec = codec;
|
||||||
|
this.base64 = base64;
|
||||||
|
this.reference = reference;
|
||||||
|
this.url = 'data:text/plain;charset=' + this.codec + ';base64,' + this.base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
var texts = [
|
||||||
|
new Text('Shift_JIS', 'g3SDQIOTg2eDgA==', 'ファントム'),
|
||||||
|
new Text('EUC-JP', 'pdWloaXzpcil4A0K', 'ファントム'),
|
||||||
|
new Text('ISO-2022-JP', 'GyRCJVUlISVzJUglYBsoQg0K', 'ファントム'),
|
||||||
|
new Text('Big5', 'pNu2SA0K', '幻象'),
|
||||||
|
new Text('GBK', 'u8PP8w0K', '幻象'),
|
||||||
|
new Text('EUC-KR', 'yK+/tQ==', '환영'),
|
||||||
|
];
|
||||||
|
|
||||||
|
texts.forEach(function (text) {
|
||||||
|
var page = webpage.create();
|
||||||
|
page.open(text.url, function() {
|
||||||
|
var decodedText = page.evaluate(function() {
|
||||||
|
return document.querySelector('pre').innerText;
|
||||||
|
});
|
||||||
|
var regex = '^' + text.reference;
|
||||||
|
assert.equal(decodedText.match(regex), text.reference);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -73,7 +73,6 @@ phantom.injectJs("./cookiejar-spec.js");
|
||||||
phantom.injectJs("./webpage-spec.js");
|
phantom.injectJs("./webpage-spec.js");
|
||||||
require("./module_spec.js");
|
require("./module_spec.js");
|
||||||
require("./require/require_spec.js");
|
require("./require/require_spec.js");
|
||||||
require("./cjk-text-codecs.js");
|
|
||||||
|
|
||||||
// Environment configuration
|
// Environment configuration
|
||||||
var jasmineEnv = jasmine.getEnv();
|
var jasmineEnv = jasmine.getEnv();
|
||||||
|
|
Loading…
Reference in New Issue