addon-sdk/source/test/test-url.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 'use strict';
michael@0 5
michael@0 6 const {
michael@0 7 URL,
michael@0 8 toFilename,
michael@0 9 fromFilename,
michael@0 10 isValidURI,
michael@0 11 getTLD,
michael@0 12 DataURL,
michael@0 13 isLocalURL } = require('sdk/url');
michael@0 14
michael@0 15 const { pathFor } = require('sdk/system');
michael@0 16 const file = require('sdk/io/file');
michael@0 17 const tabs = require('sdk/tabs');
michael@0 18 const { decode } = require('sdk/base64');
michael@0 19
michael@0 20 const httpd = require('sdk/test/httpd');
michael@0 21 const port = 8099;
michael@0 22
michael@0 23 const defaultLocation = '{\'scheme\':\'about\',\'userPass\':null,\'host\':null,\'hostname\':null,\'port\':null,\'path\':\'addons\',\'pathname\':\'addons\',\'hash\':\'\',\'href\':\'about:addons\',\'origin\':\'about:\',\'protocol\':\'about:\',\'search\':\'\'}'.replace(/'/g, '"');
michael@0 24
michael@0 25 exports.testResolve = function(assert) {
michael@0 26 assert.equal(URL('bar', 'http://www.foo.com/').toString(),
michael@0 27 'http://www.foo.com/bar');
michael@0 28
michael@0 29 assert.equal(URL('bar', 'http://www.foo.com'),
michael@0 30 'http://www.foo.com/bar');
michael@0 31
michael@0 32 assert.equal(URL('http://bar.com/', 'http://foo.com/'),
michael@0 33 'http://bar.com/',
michael@0 34 'relative should override base');
michael@0 35
michael@0 36 assert.throws(function() { URL('blah'); },
michael@0 37 /malformed URI: blah/i,
michael@0 38 'url.resolve() should throw malformed URI on base');
michael@0 39
michael@0 40 assert.throws(function() { URL('chrome://global'); },
michael@0 41 /invalid URI: chrome:\/\/global/i,
michael@0 42 'url.resolve() should throw invalid URI on base');
michael@0 43
michael@0 44 assert.throws(function() { URL('chrome://foo/bar'); },
michael@0 45 /invalid URI: chrome:\/\/foo\/bar/i,
michael@0 46 'url.resolve() should throw on bad chrome URI');
michael@0 47
michael@0 48 assert.equal(URL('', 'http://www.foo.com'),
michael@0 49 'http://www.foo.com/',
michael@0 50 'url.resolve() should add slash to end of domain');
michael@0 51 };
michael@0 52
michael@0 53 exports.testParseHttp = function(assert) {
michael@0 54 var aUrl = 'http://sub.foo.com/bar?locale=en-US&otherArg=%20x%20#myhash';
michael@0 55 var info = URL(aUrl);
michael@0 56
michael@0 57 assert.equal(info.scheme, 'http');
michael@0 58 assert.equal(info.protocol, 'http:');
michael@0 59 assert.equal(info.host, 'sub.foo.com');
michael@0 60 assert.equal(info.hostname, 'sub.foo.com');
michael@0 61 assert.equal(info.port, null);
michael@0 62 assert.equal(info.userPass, null);
michael@0 63 assert.equal(info.path, '/bar?locale=en-US&otherArg=%20x%20#myhash');
michael@0 64 assert.equal(info.pathname, '/bar');
michael@0 65 assert.equal(info.href, aUrl);
michael@0 66 assert.equal(info.hash, '#myhash');
michael@0 67 assert.equal(info.search, '?locale=en-US&otherArg=%20x%20');
michael@0 68 };
michael@0 69
michael@0 70 exports.testParseHttpSearchAndHash = function (assert) {
michael@0 71 var info = URL('https://www.moz.com/some/page.html');
michael@0 72 assert.equal(info.hash, '');
michael@0 73 assert.equal(info.search, '');
michael@0 74
michael@0 75 var hashOnly = URL('https://www.sub.moz.com/page.html#justhash');
michael@0 76 assert.equal(hashOnly.search, '');
michael@0 77 assert.equal(hashOnly.hash, '#justhash');
michael@0 78
michael@0 79 var queryOnly = URL('https://www.sub.moz.com/page.html?my=query');
michael@0 80 assert.equal(queryOnly.search, '?my=query');
michael@0 81 assert.equal(queryOnly.hash, '');
michael@0 82
michael@0 83 var qMark = URL('http://www.moz.org?');
michael@0 84 assert.equal(qMark.search, '');
michael@0 85 assert.equal(qMark.hash, '');
michael@0 86
michael@0 87 var hash = URL('http://www.moz.org#');
michael@0 88 assert.equal(hash.search, '');
michael@0 89 assert.equal(hash.hash, '');
michael@0 90
michael@0 91 var empty = URL('http://www.moz.org?#');
michael@0 92 assert.equal(hash.search, '');
michael@0 93 assert.equal(hash.hash, '');
michael@0 94
michael@0 95 var strange = URL('http://moz.org?test1#test2?test3');
michael@0 96 assert.equal(strange.search, '?test1');
michael@0 97 assert.equal(strange.hash, '#test2?test3');
michael@0 98 };
michael@0 99
michael@0 100 exports.testParseHttpWithPort = function(assert) {
michael@0 101 var info = URL('http://foo.com:5/bar');
michael@0 102 assert.equal(info.port, 5);
michael@0 103 };
michael@0 104
michael@0 105 exports.testParseChrome = function(assert) {
michael@0 106 var info = URL('chrome://global/content/blah');
michael@0 107 assert.equal(info.scheme, 'chrome');
michael@0 108 assert.equal(info.host, 'global');
michael@0 109 assert.equal(info.port, null);
michael@0 110 assert.equal(info.userPass, null);
michael@0 111 assert.equal(info.path, '/content/blah');
michael@0 112 };
michael@0 113
michael@0 114 exports.testParseAbout = function(assert) {
michael@0 115 var info = URL('about:boop');
michael@0 116 assert.equal(info.scheme, 'about');
michael@0 117 assert.equal(info.host, null);
michael@0 118 assert.equal(info.port, null);
michael@0 119 assert.equal(info.userPass, null);
michael@0 120 assert.equal(info.path, 'boop');
michael@0 121 };
michael@0 122
michael@0 123 exports.testParseFTP = function(assert) {
michael@0 124 var info = URL('ftp://1.2.3.4/foo');
michael@0 125 assert.equal(info.scheme, 'ftp');
michael@0 126 assert.equal(info.host, '1.2.3.4');
michael@0 127 assert.equal(info.port, null);
michael@0 128 assert.equal(info.userPass, null);
michael@0 129 assert.equal(info.path, '/foo');
michael@0 130 };
michael@0 131
michael@0 132 exports.testParseFTPWithUserPass = function(assert) {
michael@0 133 var info = URL('ftp://user:pass@1.2.3.4/foo');
michael@0 134 assert.equal(info.userPass, 'user:pass');
michael@0 135 };
michael@0 136
michael@0 137 exports.testToFilename = function(assert) {
michael@0 138 assert.throws(
michael@0 139 function() { toFilename('resource://nonexistent'); },
michael@0 140 /resource does not exist: resource:\/\/nonexistent\//i,
michael@0 141 'toFilename() on nonexistent resources should throw'
michael@0 142 );
michael@0 143
michael@0 144 assert.throws(
michael@0 145 function() { toFilename('http://foo.com/'); },
michael@0 146 /cannot map to filename: http:\/\/foo.com\//i,
michael@0 147 'toFilename() on http: URIs should raise error'
michael@0 148 );
michael@0 149
michael@0 150 try {
michael@0 151 assert.ok(
michael@0 152 /.*console\.xul$/.test(toFilename('chrome://global/content/console.xul')),
michael@0 153 'toFilename() w/ console.xul works when it maps to filesystem'
michael@0 154 );
michael@0 155 }
michael@0 156 catch (e) {
michael@0 157 if (/chrome url isn\'t on filesystem/.test(e.message))
michael@0 158 assert.pass('accessing console.xul in jar raises exception');
michael@0 159 else
michael@0 160 assert.fail('accessing console.xul raises ' + e);
michael@0 161 }
michael@0 162
michael@0 163 // TODO: Are there any chrome URLs that we're certain exist on the
michael@0 164 // filesystem?
michael@0 165 // assert.ok(/.*main\.js$/.test(toFilename('chrome://myapp/content/main.js')));
michael@0 166 };
michael@0 167
michael@0 168 exports.testFromFilename = function(assert) {
michael@0 169 var profileDirName = require('sdk/system').pathFor('ProfD');
michael@0 170 var fileUrl = fromFilename(profileDirName);
michael@0 171 assert.equal(URL(fileUrl).scheme, 'file',
michael@0 172 'toFilename() should return a file: url');
michael@0 173 assert.equal(fromFilename(toFilename(fileUrl)), fileUrl);
michael@0 174 };
michael@0 175
michael@0 176 exports.testURL = function(assert) {
michael@0 177 assert.ok(URL('h:foo') instanceof URL, 'instance is of correct type');
michael@0 178 assert.throws(function() URL(),
michael@0 179 /malformed URI: undefined/i,
michael@0 180 'url.URL should throw on undefined');
michael@0 181 assert.throws(function() URL(''),
michael@0 182 /malformed URI: /i,
michael@0 183 'url.URL should throw on empty string');
michael@0 184 assert.throws(function() URL('foo'),
michael@0 185 /malformed URI: foo/i,
michael@0 186 'url.URL should throw on invalid URI');
michael@0 187 assert.ok(URL('h:foo').scheme, 'has scheme');
michael@0 188 assert.equal(URL('h:foo').toString(),
michael@0 189 'h:foo',
michael@0 190 'toString should roundtrip');
michael@0 191 // test relative + base
michael@0 192 assert.equal(URL('mypath', 'http://foo').toString(),
michael@0 193 'http://foo/mypath',
michael@0 194 'relative URL resolved to base');
michael@0 195 // test relative + no base
michael@0 196 assert.throws(function() URL('path').toString(),
michael@0 197 /malformed URI: path/i,
michael@0 198 'no base for relative URI should throw');
michael@0 199
michael@0 200 let a = URL('h:foo');
michael@0 201 let b = URL(a);
michael@0 202 assert.equal(b.toString(),
michael@0 203 'h:foo',
michael@0 204 'a URL can be initialized from another URL');
michael@0 205 assert.notStrictEqual(a, b,
michael@0 206 'a URL initialized from another URL is not the same object');
michael@0 207 assert.ok(a == 'h:foo',
michael@0 208 'toString is implicit when a URL is compared to a string via ==');
michael@0 209 assert.strictEqual(a + '', 'h:foo',
michael@0 210 'toString is implicit when a URL is concatenated to a string');
michael@0 211 };
michael@0 212
michael@0 213 exports.testStringInterface = function(assert) {
michael@0 214 var EM = 'about:addons';
michael@0 215 var a = URL(EM);
michael@0 216
michael@0 217 // make sure the standard URL properties are enumerable and not the String interface bits
michael@0 218 assert.equal(Object.keys(a),
michael@0 219 'scheme,userPass,host,hostname,port,path,pathname,hash,href,origin,protocol,search',
michael@0 220 'enumerable key list check for URL.');
michael@0 221 assert.equal(
michael@0 222 JSON.stringify(a),
michael@0 223 defaultLocation,
michael@0 224 'JSON.stringify should return a object with correct props and vals.');
michael@0 225
michael@0 226 // make sure that the String interface exists and works as expected
michael@0 227 assert.equal(a.indexOf(':'), EM.indexOf(':'), 'indexOf on URL works');
michael@0 228 assert.equal(a.valueOf(), EM.valueOf(), 'valueOf on URL works.');
michael@0 229 assert.equal(a.toSource(), EM.toSource(), 'toSource on URL works.');
michael@0 230 assert.equal(a.lastIndexOf('a'), EM.lastIndexOf('a'), 'lastIndexOf on URL works.');
michael@0 231 assert.equal(a.match('t:').toString(), EM.match('t:').toString(), 'match on URL works.');
michael@0 232 assert.equal(a.toUpperCase(), EM.toUpperCase(), 'toUpperCase on URL works.');
michael@0 233 assert.equal(a.toLowerCase(), EM.toLowerCase(), 'toLowerCase on URL works.');
michael@0 234 assert.equal(a.split(':').toString(), EM.split(':').toString(), 'split on URL works.');
michael@0 235 assert.equal(a.charAt(2), EM.charAt(2), 'charAt on URL works.');
michael@0 236 assert.equal(a.charCodeAt(2), EM.charCodeAt(2), 'charCodeAt on URL works.');
michael@0 237 assert.equal(a.concat(EM), EM.concat(a), 'concat on URL works.');
michael@0 238 assert.equal(a.substr(2,3), EM.substr(2,3), 'substr on URL works.');
michael@0 239 assert.equal(a.substring(2,3), EM.substring(2,3), 'substring on URL works.');
michael@0 240 assert.equal(a.trim(), EM.trim(), 'trim on URL works.');
michael@0 241 assert.equal(a.trimRight(), EM.trimRight(), 'trimRight on URL works.');
michael@0 242 assert.equal(a.trimLeft(), EM.trimLeft(), 'trimLeft on URL works.');
michael@0 243 }
michael@0 244
michael@0 245 exports.testDataURLwithouthURI = function (assert) {
michael@0 246 let dataURL = new DataURL();
michael@0 247
michael@0 248 assert.equal(dataURL.base64, false, 'base64 is false for empty uri')
michael@0 249 assert.equal(dataURL.data, '', 'data is an empty string for empty uri')
michael@0 250 assert.equal(dataURL.mimeType, '', 'mimeType is an empty string for empty uri')
michael@0 251 assert.equal(Object.keys(dataURL.parameters).length, 0, 'parameters is an empty object for empty uri');
michael@0 252
michael@0 253 assert.equal(dataURL.toString(), 'data:,');
michael@0 254 }
michael@0 255
michael@0 256 exports.testDataURLwithMalformedURI = function (assert) {
michael@0 257 assert.throws(function() {
michael@0 258 let dataURL = new DataURL('http://www.mozilla.com/');
michael@0 259 },
michael@0 260 /Malformed Data URL: http:\/\/www.mozilla.com\//i,
michael@0 261 'DataURL raises an exception for malformed data uri'
michael@0 262 );
michael@0 263 }
michael@0 264
michael@0 265 exports.testDataURLparse = function (assert) {
michael@0 266 let dataURL = new DataURL('data:text/html;charset=US-ASCII,%3Ch1%3EHello!%3C%2Fh1%3E');
michael@0 267
michael@0 268 assert.equal(dataURL.base64, false, 'base64 is false for non base64 data uri')
michael@0 269 assert.equal(dataURL.data, '<h1>Hello!</h1>', 'data is properly decoded')
michael@0 270 assert.equal(dataURL.mimeType, 'text/html', 'mimeType is set properly')
michael@0 271 assert.equal(Object.keys(dataURL.parameters).length, 1, 'one parameters specified');
michael@0 272 assert.equal(dataURL.parameters['charset'], 'US-ASCII', 'charset parsed');
michael@0 273
michael@0 274 assert.equal(dataURL.toString(), 'data:text/html;charset=US-ASCII,%3Ch1%3EHello!%3C%2Fh1%3E');
michael@0 275 }
michael@0 276
michael@0 277 exports.testDataURLparseBase64 = function (assert) {
michael@0 278 let text = 'Awesome!';
michael@0 279 let b64text = 'QXdlc29tZSE=';
michael@0 280 let dataURL = new DataURL('data:text/plain;base64,' + b64text);
michael@0 281
michael@0 282 assert.equal(dataURL.base64, true, 'base64 is true for base64 encoded data uri')
michael@0 283 assert.equal(dataURL.data, text, 'data is properly decoded')
michael@0 284 assert.equal(dataURL.mimeType, 'text/plain', 'mimeType is set properly')
michael@0 285 assert.equal(Object.keys(dataURL.parameters).length, 1, 'one parameters specified');
michael@0 286 assert.equal(dataURL.parameters['base64'], '', 'parameter set without value');
michael@0 287 assert.equal(dataURL.toString(), 'data:text/plain;base64,' + encodeURIComponent(b64text));
michael@0 288 }
michael@0 289
michael@0 290 exports.testIsValidURI = function (assert) {
michael@0 291 validURIs().forEach(function (aUri) {
michael@0 292 assert.equal(isValidURI(aUri), true, aUri + ' is a valid URL');
michael@0 293 });
michael@0 294 };
michael@0 295
michael@0 296 exports.testIsInvalidURI = function (assert) {
michael@0 297 invalidURIs().forEach(function (aUri) {
michael@0 298 assert.equal(isValidURI(aUri), false, aUri + ' is an invalid URL');
michael@0 299 });
michael@0 300 };
michael@0 301
michael@0 302 exports.testURLFromURL = function(assert) {
michael@0 303 let aURL = URL('http://mozilla.org');
michael@0 304 let bURL = URL(aURL);
michael@0 305 assert.equal(aURL.toString(), bURL.toString(), 'Making a URL from a URL works');
michael@0 306 };
michael@0 307
michael@0 308 exports.testTLD = function(assert) {
michael@0 309 let urls = [
michael@0 310 { url: 'http://my.sub.domains.mozilla.co.uk', tld: 'co.uk' },
michael@0 311 { url: 'http://my.mozilla.com', tld: 'com' },
michael@0 312 { url: 'http://my.domains.mozilla.org.hk', tld: 'org.hk' },
michael@0 313 { url: 'chrome://global/content/blah', tld: 'global' },
michael@0 314 { url: 'data:text/plain;base64,QXdlc29tZSE=', tld: null },
michael@0 315 { url: 'https://1.2.3.4', tld: null }
michael@0 316 ];
michael@0 317
michael@0 318 urls.forEach(function (uri) {
michael@0 319 assert.equal(getTLD(uri.url), uri.tld);
michael@0 320 assert.equal(getTLD(URL(uri.url)), uri.tld);
michael@0 321 });
michael@0 322 }
michael@0 323
michael@0 324 exports.testWindowLocationMatch = function (assert, done) {
michael@0 325 let server = httpd.startServerAsync(port);
michael@0 326 server.registerPathHandler('/index.html', function (request, response) {
michael@0 327 response.write('<html><head></head><body><h1>url tests</h1></body></html>');
michael@0 328 });
michael@0 329
michael@0 330 let aUrl = 'http://localhost:' + port + '/index.html?q=aQuery#somehash';
michael@0 331 let urlObject = URL(aUrl);
michael@0 332
michael@0 333 tabs.open({
michael@0 334 url: aUrl,
michael@0 335 onReady: function (tab) {
michael@0 336 tab.attach({
michael@0 337 onMessage: function (loc) {
michael@0 338 for (let prop in loc) {
michael@0 339 assert.equal(urlObject[prop], loc[prop], prop + ' matches');
michael@0 340 }
michael@0 341
michael@0 342 tab.close(function() server.stop(done));
michael@0 343 },
michael@0 344 contentScript: '(' + function () {
michael@0 345 let res = {};
michael@0 346 // `origin` is `null` in this context???
michael@0 347 let props = 'hostname,port,pathname,hash,href,protocol,search'.split(',');
michael@0 348 props.forEach(function (prop) {
michael@0 349 res[prop] = window.location[prop];
michael@0 350 });
michael@0 351 self.postMessage(res);
michael@0 352 } + ')()'
michael@0 353 });
michael@0 354 }
michael@0 355 })
michael@0 356 };
michael@0 357
michael@0 358 exports.testURLInRegExpTest = function(assert) {
michael@0 359 let url = 'https://mozilla.org';
michael@0 360 assert.equal((new RegExp(url).test(URL(url))), true, 'URL instances work in a RegExp test');
michael@0 361 }
michael@0 362
michael@0 363 exports.testLocalURL = function(assert) {
michael@0 364 [
michael@0 365 'data:text/html;charset=utf-8,foo and bar',
michael@0 366 'data:text/plain,foo and bar',
michael@0 367 'resource://gre/modules/commonjs/',
michael@0 368 'chrome://browser/content/browser.xul'
michael@0 369 ].forEach(aUri => {
michael@0 370 assert.ok(isLocalURL(aUri), aUri + ' is a Local URL');
michael@0 371 })
michael@0 372
michael@0 373 }
michael@0 374
michael@0 375 exports.testLocalURLwithRemoteURL = function(assert) {
michael@0 376 validURIs().filter(url => !url.startsWith('data:')).forEach(aUri => {
michael@0 377 assert.ok(!isLocalURL(aUri), aUri + ' is an invalid Local URL');
michael@0 378 });
michael@0 379 }
michael@0 380
michael@0 381 exports.testLocalURLwithInvalidURL = function(assert) {
michael@0 382 invalidURIs().concat([
michael@0 383 'data:foo and bar',
michael@0 384 'resource:// must fail',
michael@0 385 'chrome:// here too'
michael@0 386 ]).forEach(aUri => {
michael@0 387 assert.ok(!isLocalURL(aUri), aUri + ' is an invalid Local URL');
michael@0 388 });
michael@0 389 }
michael@0 390
michael@0 391 function validURIs() {
michael@0 392 return [
michael@0 393 'http://foo.com/blah_blah',
michael@0 394 'http://foo.com/blah_blah/',
michael@0 395 'http://foo.com/blah_blah_(wikipedia)',
michael@0 396 'http://foo.com/blah_blah_(wikipedia)_(again)',
michael@0 397 'http://www.example.com/wpstyle/?p=364',
michael@0 398 'https://www.example.com/foo/?bar=baz&amp;inga=42&amp;quux',
michael@0 399 'http://✪df.ws/123',
michael@0 400 'http://userid:password@example.com:8080',
michael@0 401 'http://userid:password@example.com:8080/',
michael@0 402 'http://userid@example.com',
michael@0 403 'http://userid@example.com/',
michael@0 404 'http://userid@example.com:8080',
michael@0 405 'http://userid@example.com:8080/',
michael@0 406 'http://userid:password@example.com',
michael@0 407 'http://userid:password@example.com/',
michael@0 408 'http://142.42.1.1/',
michael@0 409 'http://142.42.1.1:8080/',
michael@0 410 'http://➡.ws/䨹',
michael@0 411 'http://⌘.ws',
michael@0 412 'http://⌘.ws/',
michael@0 413 'http://foo.com/blah_(wikipedia)#cite-1',
michael@0 414 'http://foo.com/blah_(wikipedia)_blah#cite-1',
michael@0 415 'http://foo.com/unicode_(✪)_in_parens',
michael@0 416 'http://foo.com/(something)?after=parens',
michael@0 417 'http://☺.damowmow.com/',
michael@0 418 'http://code.google.com/events/#&amp;product=browser',
michael@0 419 'http://j.mp',
michael@0 420 'ftp://foo.bar/baz',
michael@0 421 'http://foo.bar/?q=Test%20URL-encoded%20stuff',
michael@0 422 'http://مثال.إختبار',
michael@0 423 'http://例子.测试',
michael@0 424 'http://उदाहरण.परीक्षा',
michael@0 425 'http://-.~_!$&amp;\'()*+,;=:%40:80%2f::::::@example.com',
michael@0 426 'http://1337.net',
michael@0 427 'http://a.b-c.de',
michael@0 428 'http://223.255.255.254',
michael@0 429 // Also want to validate data-uris, localhost
michael@0 430 'http://localhost:8432/some-file.js',
michael@0 431 'data:text/plain;base64,',
michael@0 432 'data:text/html;charset=US-ASCII,%3Ch1%3EHello!%3C%2Fh1%3E',
michael@0 433 'data:text/html;charset=utf-8,'
michael@0 434 ];
michael@0 435 }
michael@0 436
michael@0 437 // Some invalidURIs are valid according to the regex used,
michael@0 438 // can be improved in the future, but better to pass some
michael@0 439 // invalid URLs than prevent valid URLs
michael@0 440
michael@0 441 function invalidURIs () {
michael@0 442 return [
michael@0 443 // 'http://',
michael@0 444 // 'http://.',
michael@0 445 // 'http://..',
michael@0 446 // 'http://../',
michael@0 447 // 'http://?',
michael@0 448 // 'http://??',
michael@0 449 // 'http://??/',
michael@0 450 // 'http://#',
michael@0 451 // 'http://##',
michael@0 452 // 'http://##/',
michael@0 453 // 'http://foo.bar?q=Spaces should be encoded',
michael@0 454 'not a url',
michael@0 455 '//',
michael@0 456 '//a',
michael@0 457 '///a',
michael@0 458 '///',
michael@0 459 // 'http:///a',
michael@0 460 'foo.com',
michael@0 461 'http:// shouldfail.com',
michael@0 462 ':// should fail',
michael@0 463 // 'http://foo.bar/foo(bar)baz quux',
michael@0 464 // 'http://-error-.invalid/',
michael@0 465 // 'http://a.b--c.de/',
michael@0 466 // 'http://-a.b.co',
michael@0 467 // 'http://a.b-.co',
michael@0 468 // 'http://0.0.0.0',
michael@0 469 // 'http://10.1.1.0',
michael@0 470 // 'http://10.1.1.255',
michael@0 471 // 'http://224.1.1.1',
michael@0 472 // 'http://1.1.1.1.1',
michael@0 473 // 'http://123.123.123',
michael@0 474 // 'http://3628126748',
michael@0 475 // 'http://.www.foo.bar/',
michael@0 476 // 'http://www.foo.bar./',
michael@0 477 // 'http://.www.foo.bar./',
michael@0 478 // 'http://10.1.1.1',
michael@0 479 // 'http://10.1.1.254'
michael@0 480 ];
michael@0 481 }
michael@0 482
michael@0 483 require('sdk/test').run(exports);

mercurial