@@ -50,15 +50,14 @@ directory_test(async (t, root) => {
5050 const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
5151 const dir_in_dir =
5252 await dir_src . getDirectoryHandle ( 'dir-in-dir' , { create : true } ) ;
53- await dir_in_dir . move ( dir_dest , "" ) ;
53+ await dir_in_dir . move ( dir_dest , '' ) ;
54+
55+ await promise_rejects_js ( t , TypeError , dir_in_dir . move ( dir_dest , '' ) ) ;
5456
5557 assert_array_equals (
56- await getSortedDirectoryEntries ( root ) , [ 'dir-dest/' , 'dir-src/' ] ) ;
57- assert_array_equals ( await getSortedDirectoryEntries ( dir_src ) , [ ] ) ;
58- assert_array_equals (
59- await getSortedDirectoryEntries ( dir_dest ) , [ 'dir-in-dir/' ] ) ;
60- assert_array_equals ( await getSortedDirectoryEntries ( dir_in_dir ) , [ ] ) ;
61- } , 'move(dir, "") to move an empty directory to a new directory' ) ;
58+ await getSortedDirectoryEntries ( dir_src ) , [ 'dir-before/' ] ) ;
59+ assert_array_equals ( await getSortedDirectoryEntries ( dir_dest ) , [ ] ) ;
60+ } , 'move(dir, "") to move a directory to a new directory fails' ) ;
6261
6362directory_test ( async ( t , root ) => {
6463 const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
@@ -75,26 +74,6 @@ directory_test(async (t, root) => {
7574 assert_array_equals ( await getSortedDirectoryEntries ( dir_in_dir ) , [ ] ) ;
7675} , 'move(dir, name) to move an empty directory to a new directory' ) ;
7776
78- directory_test ( async ( t , root ) => {
79- const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
80- const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
81- const dir_in_dir =
82- await dir_src . getDirectoryHandle ( 'dir-in-dir' , { create : true } ) ;
83- const file =
84- await createFileWithContents ( t , 'file-in-dir' , 'abc' , dir_in_dir ) ;
85- await dir_in_dir . move ( dir_dest , "" ) ;
86-
87- assert_array_equals (
88- await getSortedDirectoryEntries ( root ) , [ 'dir-dest/' , 'dir-src/' ] ) ;
89- assert_array_equals ( await getSortedDirectoryEntries ( dir_src ) , [ ] ) ;
90- assert_array_equals (
91- await getSortedDirectoryEntries ( dir_dest ) , [ 'dir-in-dir/' ] ) ;
92- assert_array_equals (
93- await getSortedDirectoryEntries ( dir_in_dir ) , [ 'file-in-dir' ] ) ;
94- // `file` should be invalidated after moving directories.
95- await promise_rejects_dom ( t , 'NotFoundError' , getFileContents ( file ) ) ;
96- } , 'move(dir, "") to move a non-empty directory to a new directory' ) ;
97-
9877directory_test ( async ( t , root ) => {
9978 const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
10079 const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
@@ -142,33 +121,6 @@ directory_test(async (t, root) => {
142121 assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
143122} , 'move(dir) can be called multiple times' ) ;
144123
145- directory_test ( async ( t , root ) => {
146- const dir1 = await root . getDirectoryHandle ( 'dir1' , { create : true } ) ;
147- const dir2 = await root . getDirectoryHandle ( 'dir2' , { create : true } ) ;
148- const handle = await createFileWithContents ( t , 'file' , 'foo' , root ) ;
149-
150- await handle . move ( dir1 , "" ) ;
151- assert_array_equals (
152- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' ] ) ;
153- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ 'file' ] ) ;
154- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ ] ) ;
155- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
156-
157- await handle . move ( dir2 , "" ) ;
158- assert_array_equals (
159- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' ] ) ;
160- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ ] ) ;
161- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ 'file' ] ) ;
162- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
163-
164- await handle . move ( root , "" ) ;
165- assert_array_equals (
166- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' , 'file' ] ) ;
167- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ ] ) ;
168- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ ] ) ;
169- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
170- } , 'move(dir, "") can be called multiple times' ) ;
171-
172124directory_test ( async ( t , root ) => {
173125 const dir1 = await root . getDirectoryHandle ( 'dir1' , { create : true } ) ;
174126 const dir2 = await root . getDirectoryHandle ( 'dir2' , { create : true } ) ;
0 commit comments