test_bug660066.js (1352B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 "use strict"; 3 4 const SIMPLEURI_SPEC = "data:text/plain,hello world"; 5 const BLOBURI_SPEC = "blob:123456"; 6 7 function do_info(text, stack) { 8 if (!stack) { 9 stack = Components.stack.caller; 10 } 11 12 dump( 13 "\n" + 14 "TEST-INFO | " + 15 stack.filename + 16 " | [" + 17 stack.name + 18 " : " + 19 stack.lineNumber + 20 "] " + 21 text + 22 "\n" 23 ); 24 } 25 26 function do_check_uri_neq(uri1, uri2) { 27 do_info("Checking equality in forward direction..."); 28 Assert.ok(!uri1.equals(uri2)); 29 Assert.ok(!uri1.equalsExceptRef(uri2)); 30 31 do_info("Checking equality in reverse direction..."); 32 Assert.ok(!uri2.equals(uri1)); 33 Assert.ok(!uri2.equalsExceptRef(uri1)); 34 } 35 36 function run_test() { 37 var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC); 38 var fileDataURI = NetUtil.newURI(BLOBURI_SPEC); 39 40 do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC); 41 do_check_uri_neq(simpleURI, fileDataURI); 42 43 do_info("Changing the nsSimpleURI spec to match the nsFileDataURI"); 44 simpleURI = simpleURI.mutate().setSpec(BLOBURI_SPEC).finalize(); 45 46 do_info("Verifying that .spec matches"); 47 Assert.equal(simpleURI.spec, fileDataURI.spec); 48 49 do_info( 50 "Checking that nsSimpleURI != nsFileDataURI despite their .spec matching" 51 ); 52 do_check_uri_neq(simpleURI, fileDataURI); 53 }