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