forked from mirrors/gecko-dev
		
	 d19d88da30
			
		
	
	
		d19d88da30
		
	
	
	
	
		
			
			MozReview-Commit-ID: BoGnB1aQxm8 --HG-- extra : rebase_source : 3014c44fb75c24616da5ca35b4e0addaf9982d9e
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function test() {
 | |
|   let {Promise} = ChromeUtils.import("resource://gre/modules/Promise.jsm", {});
 | |
|   ChromeUtils.import("resource://gre/modules/osfile.jsm");
 | |
|   let decoder = new TextDecoder();
 | |
| 
 | |
|   waitForExplicitFinish();
 | |
| 
 | |
|   SimpleTest.doesThrow(function() {
 | |
|     getTestFilePath("/browser_getTestFile.js");
 | |
|   }, "getTestFilePath rejects absolute paths");
 | |
| 
 | |
|   Promise.all([
 | |
|     OS.File.exists(getTestFilePath("browser_getTestFile.js"))
 | |
|       .then(function(exists) {
 | |
|         ok(exists, "getTestFilePath consider the path as being relative");
 | |
|       }),
 | |
| 
 | |
|     OS.File.exists(getTestFilePath("./browser_getTestFile.js"))
 | |
|       .then(function(exists) {
 | |
|         ok(exists, "getTestFilePath also accepts explicit relative path");
 | |
|       }),
 | |
| 
 | |
|     OS.File.exists(getTestFilePath("./browser_getTestFileTypo.xul"))
 | |
|       .then(function(exists) {
 | |
|         ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
 | |
|       }),
 | |
| 
 | |
|     OS.File.read(getTestFilePath("test-dir/test-file"))
 | |
|       .then(function(array) {
 | |
|         is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 1/2");
 | |
|       }),
 | |
| 
 | |
|     OS.File.read(getTestFilePath("./test-dir/test-file"))
 | |
|       .then(function(array) {
 | |
|         is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 2/2");
 | |
|       })
 | |
| 
 | |
|   ]).then(function() {
 | |
|     finish();
 | |
|   }, function(error) {
 | |
|     ok(false, error);
 | |
|     finish();
 | |
|   });
 | |
| }
 |