Bug 554707. Throw the right exception when document.open/close/write/writeln happen on an XHTML document. r=bzbarsky
This commit is contained in:
@@ -1849,7 +1849,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
|||||||
if (!IsHTML() || mDisableDocWrite) {
|
if (!IsHTML() || mDisableDocWrite) {
|
||||||
// No calling document.open() on XHTML
|
// No calling document.open() on XHTML
|
||||||
|
|
||||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool loadAsHtml5 = nsHtml5Module::sEnabled;
|
PRBool loadAsHtml5 = nsHtml5Module::sEnabled;
|
||||||
@@ -2099,7 +2099,7 @@ nsHTMLDocument::Close()
|
|||||||
if (!IsHTML()) {
|
if (!IsHTML()) {
|
||||||
// No calling document.close() on XHTML!
|
// No calling document.close() on XHTML!
|
||||||
|
|
||||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
@@ -2164,7 +2164,7 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
|||||||
if (!IsHTML() || mDisableDocWrite) {
|
if (!IsHTML() || mDisableDocWrite) {
|
||||||
// No calling document.write*() on XHTML!
|
// No calling document.write*() on XHTML!
|
||||||
|
|
||||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function test() {
|
|||||||
document.open();
|
document.open();
|
||||||
is(0, 1, "document.open succeeded");
|
is(0, 1, "document.open succeeded");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
is (e.code, DOMException.INVALID_ACCESS_ERR,
|
is (e.code, DOMException.INVALID_STATE_ERR,
|
||||||
"Wrong exception from document.open");
|
"Wrong exception from document.open");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,15 @@ function test() {
|
|||||||
document.write("aaa");
|
document.write("aaa");
|
||||||
is(0, 1, "document.write succeeded");
|
is(0, 1, "document.write succeeded");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
is (e.code, DOMException.INVALID_ACCESS_ERR,
|
is (e.code, DOMException.INVALID_STATE_ERR,
|
||||||
|
"Wrong exception from document.write");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.writeln("aaa");
|
||||||
|
is(0, 1, "document.write succeeded");
|
||||||
|
} catch (e) {
|
||||||
|
is (e.code, DOMException.INVALID_STATE_ERR,
|
||||||
"Wrong exception from document.write");
|
"Wrong exception from document.write");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +52,7 @@ function test() {
|
|||||||
document.close();
|
document.close();
|
||||||
is(0, 1, "document.close succeeded");
|
is(0, 1, "document.close succeeded");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
is (e.code, DOMException.INVALID_ACCESS_ERR,
|
is (e.code, DOMException.INVALID_STATE_ERR,
|
||||||
"Wrong exception from document.close");
|
"Wrong exception from document.close");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user