Bug 647621 - Implement document.charset and update document.inputEncoding to the latest spec. r=bz

This commit is contained in:
Masatoshi Kimura 2015-09-23 09:32:29 +09:00
parent 4bf9264cf1
commit 664155a2ac
19 changed files with 22 additions and 302 deletions

View File

@ -21,7 +21,6 @@ DEPRECATED_OPERATION(OwnerElement)
DEPRECATED_OPERATION(NodeValue)
DEPRECATED_OPERATION(TextContent)
DEPRECATED_OPERATION(EnablePrivilege)
DEPRECATED_OPERATION(InputEncoding)
DEPRECATED_OPERATION(DOMExceptionCode)
DEPRECATED_OPERATION(NoExposedProps)
DEPRECATED_OPERATION(MutationEvent)

View File

@ -2627,8 +2627,6 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
mMayStartLayout = false;
mHaveInputEncoding = true;
if (aReset) {
Reset(aChannel, aLoadGroup);
}
@ -7488,21 +7486,10 @@ nsIDocument::SetDir(const nsAString& aDirection)
NS_IMETHODIMP
nsDocument::GetInputEncoding(nsAString& aInputEncoding)
{
nsIDocument::GetInputEncoding(aInputEncoding);
nsIDocument::GetCharacterSet(aInputEncoding);
return NS_OK;
}
void
nsIDocument::GetInputEncoding(nsAString& aInputEncoding) const
{
WarnOnceAbout(eInputEncoding);
if (mHaveInputEncoding) {
return GetCharacterSet(aInputEncoding);
}
SetDOMStringToNull(aInputEncoding);
}
NS_IMETHODIMP
nsDocument::GetMozSyntheticDocument(bool *aSyntheticDocument)
{

View File

@ -2834,10 +2834,6 @@ protected:
// True if DisallowBFCaching has been called on this document.
bool mBFCacheDisallowed : 1;
// If true, we have an input encoding. If this is false, then the
// document was created entirely in memory
bool mHaveInputEncoding : 1;
bool mHasHadDefaultView : 1;
// Whether style sheet change events will be dispatched for this document

View File

@ -36,7 +36,7 @@ testDoc2 = document.implementation.createDocument("", "", null);
testDoc2.appendChild(testDoc2.createComment(" doc 2 "));
testDoc2.appendChild(testDoc2.createElement("res"));
testDoc2.documentElement.appendChild(testDoc2.createTextNode("text"));
is(testDoc2.inputEncoding, null, "wrong encoding");
is(testDoc2.inputEncoding, "UTF-8", "wrong encoding");
var testData = "blahblahblahblahblahblahblaaaaaaaah. blah.";
var extensions = [".txt",".png",".jpg",".gif",".xml", "noext"];

View File

@ -63,27 +63,26 @@ function xhrDoc(idx) {
// inputEncoding expected for that document.
var tests = [
[ frameDoc("one"), "windows-1252", "windows-1252" ],
[ frameDoc("two"), "UTF-8", "UTF-8" ],
[ frameDoc("three"), "windows-1252", "windows-1252" ],
[ frameDoc("four"), "UTF-8", "UTF-8" ],
[ frameDoc("five"), "UTF-8", "UTF-8" ],
[ frameDoc("six"), "UTF-8", "UTF-8" ],
[ frameDoc("seven"), "windows-1252", "windows-1252" ],
[ createDoc, "UTF-8", null ],
[ xhrDoc(4), "UTF-8", "UTF-8" ],
[ xhrDoc(5), "UTF-8", "UTF-8" ],
[ xhrDoc(6), "windows-1252", "windows-1252" ],
[ frameDoc("one"), "windows-1252" ],
[ frameDoc("two"), "UTF-8" ],
[ frameDoc("three"), "windows-1252" ],
[ frameDoc("four"), "UTF-8" ],
[ frameDoc("five"), "UTF-8" ],
[ frameDoc("six"), "UTF-8" ],
[ frameDoc("seven"), "windows-1252" ],
[ createDoc, "UTF-8" ],
[ xhrDoc(4), "UTF-8" ],
[ xhrDoc(5), "UTF-8" ],
[ xhrDoc(6), "windows-1252" ],
];
function doTest(idx) {
var [docGetter, expectedCharacterSet,
expectedInputEncoding] = tests[idx];
var [docGetter, expectedCharacterSet] = tests[idx];
var doc = docGetter();
// Have to be careful here to catch null vs ""
is(doc.characterSet, expectedCharacterSet, "Test " + idx + " characterSet");
is(doc.inputEncoding, expectedInputEncoding,
is(doc.inputEncoding, expectedCharacterSet,
"Test " + idx + " inputEncoding");
}

View File

@ -3,7 +3,6 @@
"Historical DOM features must be removed: createCDATASection": true,
"Historical DOM features must be removed: createAttribute": true,
"Historical DOM features must be removed: createAttributeNS": true,
"Historical DOM features must be removed: inputEncoding": true,
"Historical DOM features must be removed: getAttributeNode": true,
"Historical DOM features must be removed: getAttributeNodeNS": true,
"Historical DOM features must be removed: setAttributeNode": true,

View File

@ -41,7 +41,6 @@ var documentNuked = [
"createAttribute",
"createAttributeNS",
"createEntityReference",
"inputEncoding",
"xmlEncoding",
"xmlStandalone",
"xmlVersion",
@ -49,7 +48,6 @@ var documentNuked = [
"domConfig",
"normalizeDocument",
"renameNode",
"charset",
"defaultCharset",
"height",
"width"

View File

@ -64,7 +64,6 @@ EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code th
nsIJSONDecodeDeprecatedWarning=nsIJSON.decode is deprecated. Please use JSON.parse instead.
nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.stringify instead.
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
InputEncodingWarning=Use of inputEncoding is deprecated.
FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference.
FullScreenDeniedFocusedPlugin=Request for full-screen was denied because a windowed plugin is focused.
FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible.

View File

@ -27,6 +27,10 @@ interface Document : Node {
readonly attribute DOMString compatMode;
[Pure]
readonly attribute DOMString characterSet;
[Pure,BinaryName="characterSet"]
readonly attribute DOMString charset; // legacy alias of .characterSet
[Pure,BinaryName="characterSet"]
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
[Pure]
readonly attribute DOMString contentType;
@ -86,8 +90,6 @@ interface Document : Node {
Attr createAttribute(DOMString name);
[NewObject, Throws]
Attr createAttributeNS(DOMString? namespace, DOMString name);
[Pure]
readonly attribute DOMString? inputEncoding;
};
// http://www.whatwg.org/specs/web-apps/current-work/#the-document-object

View File

@ -393,8 +393,6 @@ XULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
mChannel = aChannel;
mHaveInputEncoding = true;
// Get the URI. Note that this should match nsDocShell::OnLoadingSite
nsresult rv =
NS_GetFinalChannelURI(aChannel, getter_AddRefs(mDocumentURI));

View File

@ -9,6 +9,9 @@
[Historical DOM features must be removed: createCDATASection]
expected: FAIL
[Historical DOM features must be removed: charset]
expected: FAIL
[DocumentType member must be nuked: internalSubset]
expected: FAIL

View File

@ -21,9 +21,6 @@
[Document interface: xmlDoc must inherit property "origin" with the proper type (3)]
expected: FAIL
[Document interface: xmlDoc must inherit property "inputEncoding" with the proper type (6)]
expected: FAIL
[Document interface: xmlDoc must inherit property "prepend" with the proper type (32)]
expected: FAIL

View File

@ -1,242 +1,8 @@
[DOMImplementation-createDocument.html]
type: testharness
[createDocument test 0: metadata for null,undefined,null]
expected: FAIL
[createDocument test 1: metadata for null,"foo",null]
expected: FAIL
[createDocument test 3: metadata for null,"f1oo",null]
expected: FAIL
[createDocument test 4: metadata for null,"foo1",null]
expected: FAIL
[createDocument test 6: null,"̀foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test 22: metadata for null,"xml",null]
expected: FAIL
[createDocument test 24: metadata for null,"xmlfoo",null]
expected: FAIL
[createDocument test 32: metadata for undefined,undefined,null]
expected: FAIL
[createDocument test 33: metadata for undefined,"foo",null]
expected: FAIL
[createDocument test 35: metadata for undefined,"f1oo",null]
expected: FAIL
[createDocument test 36: metadata for undefined,"foo1",null]
expected: FAIL
[createDocument test 40: metadata for undefined,"xml",null]
expected: FAIL
[createDocument test 42: metadata for undefined,"xmlfoo",null]
expected: FAIL
[createDocument test 46: metadata for "http://example.com/","foo",null]
expected: FAIL
[createDocument test 48: metadata for "http://example.com/","f1oo",null]
expected: FAIL
[createDocument test 49: metadata for "http://example.com/","foo1",null]
expected: FAIL
[createDocument test 51: metadata for "http://example.com/","f:oo",null]
expected: FAIL
[createDocument test 53: metadata for "http://example.com/","_:_",null]
expected: FAIL
[createDocument test 54: metadata for "http://example.com/","_:h0",null]
expected: FAIL
[createDocument test 55: metadata for "http://example.com/","_:test",null]
expected: FAIL
[createDocument test 56: metadata for "http://example.com/","l_:_",null]
expected: FAIL
[createDocument test 57: metadata for "http://example.com/","ns:_0",null]
expected: FAIL
[createDocument test 58: metadata for "http://example.com/","ns:a0",null]
expected: FAIL
[createDocument test 59: metadata for "http://example.com/","ns0:test",null]
expected: FAIL
[createDocument test 60: metadata for "http://example.com/","a.b:c",null]
expected: FAIL
[createDocument test 61: metadata for "http://example.com/","a-b:c",null]
expected: FAIL
[createDocument test 62: metadata for "http://example.com/","a-b:c",null]
expected: FAIL
[createDocument test 63: metadata for "http://example.com/","xml",null]
expected: FAIL
[createDocument test 65: metadata for "http://example.com/","XMLNS",null]
expected: FAIL
[createDocument test 66: metadata for "http://example.com/","xmlfoo",null]
expected: FAIL
[createDocument test 68: metadata for "http://example.com/","XML:foo",null]
expected: FAIL
[createDocument test 70: metadata for "http://example.com/","XMLNS:foo",null]
expected: FAIL
[createDocument test 71: metadata for "http://example.com/","xmlfoo:bar",null]
expected: FAIL
[createDocument test 100: metadata for "/","foo",null]
expected: FAIL
[createDocument test 102: metadata for "/","f1oo",null]
expected: FAIL
[createDocument test 103: metadata for "/","foo1",null]
expected: FAIL
[createDocument test 105: metadata for "/","f:oo",null]
expected: FAIL
[createDocument test 107: metadata for "/","xml",null]
expected: FAIL
[createDocument test 109: metadata for "/","xmlfoo",null]
expected: FAIL
[createDocument test 112: metadata for "/","xmlfoo:bar",null]
expected: FAIL
[createDocument test 113: metadata for "http://www.w3.org/XML/1998/namespace","foo",null]
expected: FAIL
[createDocument test 115: metadata for "http://www.w3.org/XML/1998/namespace","f1oo",null]
expected: FAIL
[createDocument test 116: metadata for "http://www.w3.org/XML/1998/namespace","foo1",null]
expected: FAIL
[createDocument test 118: metadata for "http://www.w3.org/XML/1998/namespace","f:oo",null]
expected: FAIL
[createDocument test 120: metadata for "http://www.w3.org/XML/1998/namespace","xml",null]
expected: FAIL
[createDocument test 122: metadata for "http://www.w3.org/XML/1998/namespace","xmlfoo",null]
expected: FAIL
[createDocument test 123: metadata for "http://www.w3.org/XML/1998/namespace","xml:foo",null]
expected: FAIL
[createDocument test 125: metadata for "http://www.w3.org/XML/1998/namespace","xmlfoo:bar",null]
expected: FAIL
[createDocument test 136: metadata for "http://www.w3.org/2000/xmlns/","xmlns",null]
expected: FAIL
[createDocument test 139: metadata for "http://www.w3.org/2000/xmlns/","xmlns:foo",null]
expected: FAIL
[createDocument test 142: metadata for "foo:","foo",null]
expected: FAIL
[createDocument test 144: metadata for "foo:","f1oo",null]
expected: FAIL
[createDocument test 145: metadata for "foo:","foo1",null]
expected: FAIL
[createDocument test 147: metadata for "foo:","f:oo",null]
expected: FAIL
[createDocument test 149: metadata for "foo:","xml",null]
expected: FAIL
[createDocument test 151: metadata for "foo:","xmlfoo",null]
expected: FAIL
[createDocument test 154: metadata for "foo:","xmlfoo:bar",null]
expected: FAIL
[createDocument test 156: metadata for null,null,null]
expected: FAIL
[createDocument test 157: metadata for null,"",null]
expected: FAIL
[createDocument test 158: metadata for undefined,null,undefined]
expected: FAIL
[createDocument test 159: metadata for undefined,undefined,undefined]
expected: FAIL
[createDocument test 160: metadata for undefined,"",undefined]
expected: FAIL
[createDocument test 161: metadata for "http://example.com/",null,null]
expected: FAIL
[createDocument test 162: metadata for "http://example.com/","",null]
expected: FAIL
[createDocument test 163: metadata for "/",null,null]
expected: FAIL
[createDocument test 164: metadata for "/","",null]
expected: FAIL
[createDocument test 165: metadata for "http://www.w3.org/XML/1998/namespace",null,null]
expected: FAIL
[createDocument test 166: metadata for "http://www.w3.org/XML/1998/namespace","",null]
expected: FAIL
[createDocument test 167: metadata for "http://www.w3.org/2000/xmlns/",null,null]
expected: FAIL
[createDocument test 168: metadata for "http://www.w3.org/2000/xmlns/","",null]
expected: FAIL
[createDocument test 169: metadata for "foo:",null,null]
expected: FAIL
[createDocument test 170: metadata for "foo:","",null]
expected: FAIL
[createDocument test 171: metadata for null,null,DocumentType node]
expected: FAIL
[createDocument test 172: metadata for null,null,DocumentType node]
expected: FAIL
[createDocument test 173: metadata for null,null,DocumentType node]
expected: FAIL
[createDocument test 174: metadata for null,null,DocumentType node]
expected: FAIL
[createDocument test 175: metadata for null,null,DocumentType node]
expected: FAIL
[createDocument test 176: metadata for null,"foo",DocumentType node]
expected: FAIL
[createDocument test 177: metadata for "foo",null,DocumentType node]
expected: FAIL
[createDocument test 178: metadata for "foo","bar",DocumentType node]
expected: FAIL

View File

@ -1,5 +0,0 @@
[DOMImplementation-createHTMLDocument.html]
type: testharness
[createHTMLDocument(): metadata]
expected: FAIL

View File

@ -1,8 +1,5 @@
[Document-constructor.html]
type: testharness
[new Document(): metadata]
expected: FAIL
[new Document(): URL parsing]
expected: FAIL

View File

@ -1,11 +1,5 @@
[Node-properties.html]
type: testharness
[foreignDoc.inputEncoding]
expected: FAIL
[xmlDoc.inputEncoding]
expected: FAIL
[xmlElement.namespaceURI]
expected: FAIL

View File

@ -1,5 +0,0 @@
[DOMParser-parseFromString-html.html]
type: testharness
[inputEncoding]
expected: FAIL

View File

@ -211,9 +211,6 @@
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "origin" with the proper type (3)]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "inputEncoding" with the proper type (6)]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "styleSheetSets" with the proper type (31)]
expected: FAIL

View File

@ -64,7 +64,6 @@ EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code tha
nsIJSONDecodeDeprecatedWarning=nsIJSON.decode is deprecated. Please use JSON.parse instead.
nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.stringify instead.
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
InputEncodingWarning=Use of inputEncoding is deprecated.
FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference.
FullScreenDeniedFocusedPlugin=Request for full-screen was denied because a windowed plugin is focused.
FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible.