netwerk/test/unit/test_bug660066.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 Components.utils.import("resource://gre/modules/NetUtil.jsm");
michael@0 3 const SIMPLEURI_SPEC = "data:text/plain,hello world";
michael@0 4 const BLOBURI_SPEC = "blob:123456";
michael@0 5
michael@0 6 function do_info(text, stack) {
michael@0 7 if (!stack)
michael@0 8 stack = Components.stack.caller;
michael@0 9
michael@0 10 dump( "\n" +
michael@0 11 "TEST-INFO | " + stack.filename + " | [" + stack.name + " : " +
michael@0 12 stack.lineNumber + "] " + text + "\n");
michael@0 13 }
michael@0 14
michael@0 15 function do_check_uri_neq(uri1, uri2)
michael@0 16 {
michael@0 17 do_info("Checking equality in forward direction...");
michael@0 18 do_check_false(uri1.equals(uri2));
michael@0 19 do_check_false(uri1.equalsExceptRef(uri2));
michael@0 20
michael@0 21 do_info("Checking equality in reverse direction...");
michael@0 22 do_check_false(uri2.equals(uri1));
michael@0 23 do_check_false(uri2.equalsExceptRef(uri1));
michael@0 24 }
michael@0 25
michael@0 26 function run_test()
michael@0 27 {
michael@0 28 var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC);
michael@0 29 var fileDataURI = NetUtil.newURI(BLOBURI_SPEC);
michael@0 30
michael@0 31 do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC);
michael@0 32 do_check_uri_neq(simpleURI, fileDataURI);
michael@0 33
michael@0 34 do_info("Changing the nsSimpleURI spec to match the nsFileDataURI");
michael@0 35 simpleURI.spec = BLOBURI_SPEC;
michael@0 36
michael@0 37 do_info("Verifying that .spec matches");
michael@0 38 do_check_eq(simpleURI.spec, fileDataURI.spec);
michael@0 39
michael@0 40 do_info("Checking that nsSimpleURI != nsFileDataURI despite their .spec matching")
michael@0 41 do_check_uri_neq(simpleURI, fileDataURI);
michael@0 42 }

mercurial