-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ttwf shanghai 2013] add test cases for http://www.w3.org/TR/FileAPI/#enctype #283
Merged
Ms2ger
merged 6 commits into
web-platform-tests:master
from
march1993:submissions/march1993/FileAPI-Blob
Jan 25, 2014
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba9e612
add blob determing encoding
march1993 e80aa1a
fix the link
march1993 4df087c
remove unreferenced file Blob.js
march1993 8c8fa10
moved the dictionary
march1993 970dbbb
move the dictionary
march1993 31f3b78
remove reductant files
march1993 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
FileAPI/tests/submissions/march1993/Determining-Encoding.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>FileAPI Test: Blob Determing Encoding</title> | ||
<link ref="author" title="march1993" href="mailto:march511@gmail.com"> | ||
<link rel=help href="http://www.w3.org/TR/FileAPI/#enctypes"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/Blob.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var t = async_test("Blob Determing Encoding with encoding argument"); | ||
t.step(function() { | ||
// string 'hello' | ||
var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray]); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the ArrayBuffer through UTF-16BE.") | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob, "UTF-16BE"); | ||
}); | ||
|
||
var t = async_test("Blob Determing Encoding with type attribute"); | ||
t.step(function() { | ||
var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray], {type:"text/plain;charset=UTF-16BE"}); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the ArrayBuffer through UTF-16BE.") | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob); | ||
}); | ||
|
||
|
||
var t = async_test("Blob Determing Encoding with UTF-8 BOM"); | ||
t.step(function() { | ||
var data = [0xEF,0xBB,0xBF,0x68,0x65,0x6C,0x6C,0x6F]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray]); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the blob with UTF-8."); | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob); | ||
}); | ||
|
||
var t = async_test("Blob Determing Encoding without anything implying charset."); | ||
t.step(function() { | ||
var data = [0x68,0x65,0x6C,0x6C,0x6F]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray]); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the blob by default with UTF-8."); | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob); | ||
}); | ||
|
||
var t = async_test("Blob Determing Encoding with UTF-16BE BOM"); | ||
t.step(function() { | ||
var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray]); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the ArrayBuffer through UTF-16BE."); | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob); | ||
}); | ||
|
||
var t = async_test("Blob Determing Encoding with UTF-16LE BOM"); | ||
t.step(function() { | ||
var data = [0xFF,0xFE,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F,0x00]; | ||
var testStringArray = new ArrayBuffer(data.length); | ||
var dataView = new DataView(testStringArray); | ||
data.forEach(function(v,i){ | ||
dataView.setInt8(i, v); | ||
}); | ||
var testString = "hello"; | ||
|
||
var blob = new Blob([testStringArray]); | ||
var reader = new FileReader(); | ||
var strResult = ""; | ||
|
||
reader.onloadend = t.step_func_done (function(event) { | ||
strResult = reader.result; | ||
assert_equals(strResult, testString, "The FileReader should read the ArrayBuffer through UTF-16LE."); | ||
t.done(); | ||
}, reader); | ||
|
||
reader.readAsText(blob); | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Determining-Encoding.html |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This support file is unreferenced.