OSDN Git Service

openメソッドの引数の途中で、文字列以外のオブジェクトがあったとき、ファイルの読み込みをとめるように修正
authordhrname <dhrname@users.sourceforge.jp>
Wed, 18 Sep 2013 12:35:59 +0000 (21:35 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Wed, 18 Sep 2013 12:35:59 +0000 (21:35 +0900)
tool/funcproto/FuncSpecRunner.html
tool/funcproto/openfile.js

index 0939492..c4365f3 100644 (file)
@@ -62,10 +62,24 @@ function f (file) {
     });\r
     it("default property", function() {\r
       expect(f.open("a")).toEqual(f);\r
-      f = function() {\r
-        expect(arguments[1][0]).toEqual("h");\r
+      f = function(file, a, b, c) {\r
+        describe("File::open2", function() {\r
+          it("default property", function() {\r
+            expect(a[0]).toEqual("h");\r
+            expect(b).toEqual(0);\r
+            expect(c).toEqual("a.txt");\r
+            expect(file[0]).toEqual("");\r
+            expect(file[1]).toBeUndefined();\r
+            expect(file[2]).toBeUndefined();\r
+            expect(file[3]).toBeUndefined();\r
+            expect(file["a.txt"]).toBeUndefined();\r
+            expect(file["a"]).toEqual("");\r
+            expect(file.read()).toEqual("");\r
+          });\r
+        });\r
+        __start_();\r
       };\r
-      f.open("a", ["h"]);\r
+      f.open("a", ["h"], 0, "a.txt");\r
     });\r
     it("arguments inheritance", function() {\r
       expect(args[1]).toEqual("b.txt");\r
index edd0aa4..7aeae80 100644 (file)
@@ -26,9 +26,9 @@ if (!Function.prototype.open) {
       if (xhr.readyState === 4) {\r
         if ((xhr.status === 200) || (xhr.status > 400)) {\r
           var text = (xhr.status === 200) ? xhr.responseText : "";\r
-          handle.push((handle[fileName] = text));\r
+          fileName && handle.push((handle[fileName] = text));\r
           if (fileNames.length !== 0) {\r
-            fileName = fileNames.shift().toString();\r
+            fileName = fileNames.shift();\r
             f();\r
           } else {                                   //Load End\r
             xhr.onreadystatechange = Function.empty; //to solve the problem about a memory leak for IE 8\r
@@ -39,6 +39,13 @@ if (!Function.prototype.open) {
       }\r
     };\r
     var f = function() {\r
+      if (!fileName || (typeof fileName !== "string")) {\r
+        /*stop loading files*/\r
+        fileNames = [];\r
+        fileName = null;\r
+        xhr.onreadystatechange();\r
+        return;\r
+      }\r
       xhr.open("GET", fileName, true);\r
       xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");\r
       xhr.send(null);\r