Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet |
michael@0 | 4 | href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 5 | type="text/css"?> |
michael@0 | 6 | <!-- |
michael@0 | 7 | https://bugzilla.mozilla.org/show_bug.cgi?id=607114.xul |
michael@0 | 8 | --> |
michael@0 | 9 | <window title="Mozilla Bug 607114" |
michael@0 | 10 | xmlns:html="http://www.w3.org/1999/xhtml" |
michael@0 | 11 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 15 | |
michael@0 | 16 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 17 | <a target="_blank" |
michael@0 | 18 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=607114"> |
michael@0 | 19 | Mozilla Bug 607114</a> |
michael@0 | 20 | <p id="display"></p> |
michael@0 | 21 | <div id="content" style="display: none"> |
michael@0 | 22 | |
michael@0 | 23 | </div> |
michael@0 | 24 | <pre id="test"> |
michael@0 | 25 | </pre> |
michael@0 | 26 | </body> |
michael@0 | 27 | |
michael@0 | 28 | <script class="testbody" type="application/javascript"> |
michael@0 | 29 | <![CDATA[ |
michael@0 | 30 | |
michael@0 | 31 | /** Test for Bug 607114 **/ |
michael@0 | 32 | |
michael@0 | 33 | var file = Components.classes["@mozilla.org/file/directory_service;1"] |
michael@0 | 34 | .getService(Components.interfaces.nsIProperties) |
michael@0 | 35 | .get("CurWorkD", Components.interfaces.nsIFile); |
michael@0 | 36 | |
michael@0 | 37 | // man I wish this were simpler ... |
michael@0 | 38 | file.append("chrome"); |
michael@0 | 39 | file.append("content"); |
michael@0 | 40 | file.append("base"); |
michael@0 | 41 | file.append("test"); |
michael@0 | 42 | file.append("chrome"); |
michael@0 | 43 | file.append("fileconstructor_file.png"); |
michael@0 | 44 | |
michael@0 | 45 | doTest(new File(file.path)); |
michael@0 | 46 | doTest(new File(file)); |
michael@0 | 47 | function doTest(domfile) { |
michael@0 | 48 | ok(domfile instanceof File, "File() should return a File"); |
michael@0 | 49 | is(domfile.type, "image/png", "File should be a PNG"); |
michael@0 | 50 | is(domfile.size, 95, "File has size 95 (and more importantly we can read it)"); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | try { |
michael@0 | 54 | var boomfile = new File(); |
michael@0 | 55 | ok(false, "This should never be reached!"); |
michael@0 | 56 | } catch (e) { |
michael@0 | 57 | ok(true, "Botched file constructor attempts throw and do not crash."); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | try { |
michael@0 | 61 | var nonexistentfile = new File("i/sure/hope/this/does/not/exist/anywhere.txt"); |
michael@0 | 62 | ok(false, "This should never be reached!"); |
michael@0 | 63 | } catch (e) { |
michael@0 | 64 | ok(true, "Attempt to construct a non-existent file should fail."); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | try { |
michael@0 | 68 | var dir = Components.classes["@mozilla.org/file/directory_service;1"] |
michael@0 | 69 | .getService(Components.interfaces.nsIProperties) |
michael@0 | 70 | .get("CurWorkD", Components.interfaces.nsIFile); |
michael@0 | 71 | var dirfile = new File(dir); |
michael@0 | 72 | ok(false, "This should never be reached!"); |
michael@0 | 73 | } catch (e) { |
michael@0 | 74 | ok(true, "Attempt to construct a file from a directory should fail."); |
michael@0 | 75 | } |
michael@0 | 76 | ]]> |
michael@0 | 77 | </script> |
michael@0 | 78 | |
michael@0 | 79 | </window> |