michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: Components.utils.import("resource://gre/modules/NetUtil.jsm"); michael@0: const SIMPLEURI_SPEC = "data:text/plain,hello world"; michael@0: const BLOBURI_SPEC = "blob:123456"; michael@0: michael@0: function do_info(text, stack) { michael@0: if (!stack) michael@0: stack = Components.stack.caller; michael@0: michael@0: dump( "\n" + michael@0: "TEST-INFO | " + stack.filename + " | [" + stack.name + " : " + michael@0: stack.lineNumber + "] " + text + "\n"); michael@0: } michael@0: michael@0: function do_check_uri_neq(uri1, uri2) michael@0: { michael@0: do_info("Checking equality in forward direction..."); michael@0: do_check_false(uri1.equals(uri2)); michael@0: do_check_false(uri1.equalsExceptRef(uri2)); michael@0: michael@0: do_info("Checking equality in reverse direction..."); michael@0: do_check_false(uri2.equals(uri1)); michael@0: do_check_false(uri2.equalsExceptRef(uri1)); michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC); michael@0: var fileDataURI = NetUtil.newURI(BLOBURI_SPEC); michael@0: michael@0: do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC); michael@0: do_check_uri_neq(simpleURI, fileDataURI); michael@0: michael@0: do_info("Changing the nsSimpleURI spec to match the nsFileDataURI"); michael@0: simpleURI.spec = BLOBURI_SPEC; michael@0: michael@0: do_info("Verifying that .spec matches"); michael@0: do_check_eq(simpleURI.spec, fileDataURI.spec); michael@0: michael@0: do_info("Checking that nsSimpleURI != nsFileDataURI despite their .spec matching") michael@0: do_check_uri_neq(simpleURI, fileDataURI); michael@0: }