Commit 3b0407c5 authored by jsbell@chromium.org's avatar jsbell@chromium.org

Encoding API: Expose 'fatal' and 'ignoreBOM' readonly attributes

From private conversation with annevk - make the properties of the
TextDecoder object inspectable.

BUG=375847

Review URL: https://codereview.chromium.org/292243003

git-svn-id: svn://svn.chromium.org/blink/trunk@174977 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 637349b2
......@@ -33,5 +33,6 @@ PASS Fatal flag: utf-8 - lead surrogate
PASS Fatal flag: utf-8 - trail surrogate
PASS Fatal flag: utf-8 - surrogate pair
PASS Fatal flag: utf-16le - truncated code unit
PASS The fatal attribute of TextDecoder
Harness: the test ran to completion.
......@@ -62,4 +62,12 @@ bad.forEach(function(t) {
}, 'Fatal flag: ' + t.encoding + ' - ' + t.name);
});
test(function() {
assert_true('fatal' in new TextDecoder(), 'The fatal attribute should exist on TextDecoder.');
assert_equals(typeof new TextDecoder().fatal, 'boolean', 'The type of the fatal attribute should be boolean.');
assert_false(new TextDecoder().fatal, 'The fatal attribute should default to false.');
assert_true(new TextDecoder('utf-8', {fatal: true}).fatal, 'The fatal attribute can be set using an option.');
}, 'The fatal attribute of TextDecoder');
</script>
......@@ -2,5 +2,6 @@ This is a testharness.js-based test.
PASS BOM is ignored if ignoreBOM option is specified: utf-8
PASS BOM is ignored if ignoreBOM option is specified: utf-16le
PASS BOM is ignored if ignoreBOM option is specified: utf-16be
PASS The ignoreBOM attribute of TextDecoder
Harness: the test ran to completion.
......@@ -34,4 +34,12 @@ cases.forEach(function(testCase) {
}, 'BOM is ignored if ignoreBOM option is specified: ' + testCase.encoding);
});
test(function() {
assert_true('ignoreBOM' in new TextDecoder(), 'The ignoreBOM attribute should exist on TextDecoder.');
assert_equals(typeof new TextDecoder().ignoreBOM, 'boolean', 'The type of the ignoreBOM attribute should be boolean.');
assert_false(new TextDecoder().ignoreBOM, 'The ignoreBOM attribute should default to false.');
assert_true(new TextDecoder('utf-8', {ignoreBOM: true}).ignoreBOM, 'The ignoreBOM attribute can be set using an option.');
}, 'The ignoreBOM attribute of TextDecoder');
</script>
......@@ -50,6 +50,8 @@ public:
// Implement the IDL
String encoding() const;
bool fatal() const { return m_fatal; }
bool ignoreBOM() const { return m_ignoreBOM; }
String decode(ArrayBufferView*, const Dictionary&, ExceptionState&);
String decode(ExceptionState& exceptionState) { return decode(0, Dictionary(), exceptionState); }
......
......@@ -37,5 +37,7 @@
MeasureAs=TextDecoderConstructor
] interface TextDecoder {
readonly attribute DOMString encoding;
readonly attribute boolean fatal;
readonly attribute boolean ignoreBOM;
[RaisesException, MeasureAs=TextDecoderDecode] DOMString decode(optional ArrayBufferView input, optional Dictionary options);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment