fune/netwerk/test/unit/test_bug660066.js
Kris Maglione 918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00

42 lines
1.3 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const SIMPLEURI_SPEC = "data:text/plain,hello world";
const BLOBURI_SPEC = "blob:123456";
function do_info(text, stack) {
if (!stack)
stack = Components.stack.caller;
dump( "\n" +
"TEST-INFO | " + stack.filename + " | [" + stack.name + " : " +
stack.lineNumber + "] " + text + "\n");
}
function do_check_uri_neq(uri1, uri2)
{
do_info("Checking equality in forward direction...");
Assert.ok(!uri1.equals(uri2));
Assert.ok(!uri1.equalsExceptRef(uri2));
do_info("Checking equality in reverse direction...");
Assert.ok(!uri2.equals(uri1));
Assert.ok(!uri2.equalsExceptRef(uri1));
}
function run_test()
{
var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC);
var fileDataURI = NetUtil.newURI(BLOBURI_SPEC);
do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC);
do_check_uri_neq(simpleURI, fileDataURI);
do_info("Changing the nsSimpleURI spec to match the nsFileDataURI");
simpleURI = simpleURI.mutate().setSpec(BLOBURI_SPEC).finalize();
do_info("Verifying that .spec matches");
Assert.equal(simpleURI.spec, fileDataURI.spec);
do_info("Checking that nsSimpleURI != nsFileDataURI despite their .spec matching")
do_check_uri_neq(simpleURI, fileDataURI);
}