netwerk/test/unit/test_bug660066.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/test/unit/test_bug660066.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +Components.utils.import("resource://gre/modules/NetUtil.jsm");
     1.6 +const SIMPLEURI_SPEC = "data:text/plain,hello world";
     1.7 +const BLOBURI_SPEC = "blob:123456";
     1.8 +
     1.9 +function do_info(text, stack) {
    1.10 +  if (!stack)
    1.11 +    stack = Components.stack.caller;
    1.12 +
    1.13 +  dump( "\n" +
    1.14 +       "TEST-INFO | " + stack.filename + " | [" + stack.name + " : " +
    1.15 +       stack.lineNumber + "] " + text + "\n");
    1.16 +}
    1.17 +
    1.18 +function do_check_uri_neq(uri1, uri2)
    1.19 +{
    1.20 +  do_info("Checking equality in forward direction...");
    1.21 +  do_check_false(uri1.equals(uri2));
    1.22 +  do_check_false(uri1.equalsExceptRef(uri2));
    1.23 +
    1.24 +  do_info("Checking equality in reverse direction...");
    1.25 +  do_check_false(uri2.equals(uri1));
    1.26 +  do_check_false(uri2.equalsExceptRef(uri1));
    1.27 +}
    1.28 +
    1.29 +function run_test()
    1.30 +{
    1.31 +  var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC);
    1.32 +  var fileDataURI = NetUtil.newURI(BLOBURI_SPEC);
    1.33 +
    1.34 +  do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC);
    1.35 +  do_check_uri_neq(simpleURI, fileDataURI);
    1.36 +
    1.37 +  do_info("Changing the nsSimpleURI spec to match the nsFileDataURI");
    1.38 +  simpleURI.spec = BLOBURI_SPEC;
    1.39 +
    1.40 +  do_info("Verifying that .spec matches");
    1.41 +  do_check_eq(simpleURI.spec, fileDataURI.spec);
    1.42 +
    1.43 +  do_info("Checking that nsSimpleURI != nsFileDataURI despite their .spec matching")
    1.44 +  do_check_uri_neq(simpleURI, fileDataURI);
    1.45 +}

mercurial