Backed out accidentally committed 192d50641f83
--HG-- extra : rebase_source : 0a574802c654de30fc3c0dd68b3492a8d6cc4209
This commit is contained in:
Родитель
b4e30eb15a
Коммит
0655e8a399
|
@ -259,6 +259,20 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
|
|||
mChannel = nsnull;
|
||||
}
|
||||
|
||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
||||
uri,
|
||||
NodePrincipal(),
|
||||
this,
|
||||
EmptyCString(), // mime type
|
||||
nsnull, // extra
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
nsContentUtils::GetSecurityManager());
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
return NS_ERROR_CONTENT_BLOCKED;
|
||||
}
|
||||
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
uri,
|
||||
nsnull,
|
||||
|
|
|
@ -10,6 +10,17 @@
|
|||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
function runTest() {
|
||||
var tests = execTests();
|
||||
function execNext() {
|
||||
try {
|
||||
tests.next();
|
||||
setTimeout(execNext, 0);
|
||||
} catch (e) {}
|
||||
}
|
||||
execNext();
|
||||
}
|
||||
|
||||
function execTests() {
|
||||
var e = document.getElementById("edit");
|
||||
var doc = e.contentDocument;
|
||||
|
@ -189,7 +200,7 @@ function execTests() {
|
|||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(execTests);
|
||||
addLoadEvent(runTest);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1948,24 +1948,10 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
if (NS_FAILED(res)) return res;
|
||||
if (*aCancel) return NS_OK;
|
||||
|
||||
res = mHTMLEditor->ExtendSelectionForDelete(aSelection, &aAction);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// We should delete nothing.
|
||||
if (aAction == nsIEditor::eNone)
|
||||
return NS_OK;
|
||||
|
||||
// ExtendSelectionForDelete() may have changed the selection, update it
|
||||
res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(startNode), &startOffset);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!startNode) return NS_ERROR_FAILURE;
|
||||
|
||||
res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
|
||||
if (bCollapsed)
|
||||
{
|
||||
// what's in the direction we are deleting?
|
||||
nsWSRunObject wsObj(mHTMLEditor, startNode, startOffset);
|
||||
nsCOMPtr<nsIDOMNode> visNode;
|
||||
|
@ -2010,6 +1996,9 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
}
|
||||
else
|
||||
{
|
||||
res = mHTMLEditor->ExtendSelectionForDelete(aSelection, &aAction);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
res = aSelection->GetRangeAt(0, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -2026,8 +2015,6 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
NS_ASSERTION(container == visNode, "selection end not in visNode");
|
||||
#endif
|
||||
|
||||
res = range->GetStartOffset(&so);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = range->GetEndOffset(&eo);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ _TEST_FILES = test_bug288789.html \
|
|||
test_bug469613.xul \
|
||||
test_character_movement.html \
|
||||
test_word_movement.html \
|
||||
test_backspace_delete.xul \
|
||||
test_backspace_delete.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
|
@ -1,63 +1,62 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
title="Test BackSpace/Delete Keys">
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test BackSpace/Delete Keys</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: block">
|
||||
<div contentEditable id="editor"></div>
|
||||
</div>
|
||||
<p id="catch">Catch-all
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript;version=1.7">
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 157546, 417745 **/
|
||||
|
||||
function execTests() {
|
||||
var e = document.getElementById("edit");
|
||||
var doc = e.contentDocument;
|
||||
var win = e.contentWindow;
|
||||
var root = doc.documentElement;
|
||||
var editor = doc.body;
|
||||
var sel = win.getSelection();
|
||||
// Work around bug 474255 --- we need to have nonempty content before we turn on
|
||||
// editing, or the tests below break because the editor doesn't notice when we
|
||||
// insert non-empty content using innerHTML.
|
||||
editor.innerHTML = "Bogus!";
|
||||
doc.designMode='on';
|
||||
win.focus();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// This seems to be necessary because the selection is not set up properly otherwise
|
||||
setTimeout(test, 0);
|
||||
|
||||
var eatSpace;
|
||||
|
||||
function getPrefs() {
|
||||
const prefSvcContractID = "@mozilla.org/preferences-service;1";
|
||||
const prefSvcIID = Components.interfaces.nsIPrefService;
|
||||
return Components.classes[prefSvcContractID].getService(prefSvcIID)
|
||||
.getBranch("layout.word_select.");
|
||||
}
|
||||
|
||||
function setEatSpace(newValue) {
|
||||
getPrefs().setBoolPref("eat_space_to_next_word", newValue);
|
||||
eatSpace = newValue;
|
||||
}
|
||||
|
||||
function restoreEatSpace() {
|
||||
try {
|
||||
getPrefs().clearUserPref("eat_space_to_next_word");
|
||||
} catch(ex) {}
|
||||
}
|
||||
|
||||
function test() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var eatSpace;
|
||||
|
||||
function getPrefs() {
|
||||
const prefSvcContractID = "@mozilla.org/preferences-service;1";
|
||||
const prefSvcIID = Components.interfaces.nsIPrefService;
|
||||
return Components.classes[prefSvcContractID].getService(prefSvcIID)
|
||||
.getBranch("layout.word_select.");
|
||||
}
|
||||
|
||||
function setEatSpace(newValue) {
|
||||
getPrefs().setBoolPref("eat_space_to_next_word", newValue);
|
||||
eatSpace = newValue;
|
||||
}
|
||||
|
||||
function restoreEatSpace() {
|
||||
try {
|
||||
getPrefs().clearUserPref("eat_space_to_next_word");
|
||||
} catch(ex) {}
|
||||
}
|
||||
|
||||
function doCommand(cmd) {
|
||||
var controller = document.commandDispatcher.getControllerForCommand(cmd);
|
||||
if (controller) {
|
||||
controller.doCommand(cmd);
|
||||
}
|
||||
}
|
||||
var wordSelModifiers =
|
||||
(navigator.platform.indexOf("Mac") >= 0) ?
|
||||
{shiftKey:true, altKey:true} : {shiftKey:true, ctrlKey:true};
|
||||
var sel = window.getSelection();
|
||||
var editor = document.getElementById("editor");
|
||||
|
||||
function testRight(node, offset) {
|
||||
doCommand("cmd_charNext");
|
||||
var msg = "Right movement broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
synthesizeKey("VK_RIGHT", {});
|
||||
is(sel.anchorNode, node, "Right movement broken in \"" + editor.innerHTML + "\"");
|
||||
is(sel.anchorOffset, offset, "Right movement broken in \"" + editor.innerHTML + "\"");
|
||||
}
|
||||
|
||||
function selErrString(dir) {
|
||||
|
@ -65,7 +64,7 @@ function execTests() {
|
|||
}
|
||||
|
||||
function testWordSelRight(startNode, startOffset, endNode, endOffset) {
|
||||
doCommand("cmd_selectWordNext");
|
||||
synthesizeKey("VK_RIGHT", wordSelModifiers);
|
||||
var selRange = sel.getRangeAt(0);
|
||||
is(selRange.startContainer, startNode, selErrString("Word right"));
|
||||
is(selRange.startOffset, startOffset, selErrString("Word right"));
|
||||
|
@ -74,35 +73,17 @@ function execTests() {
|
|||
}
|
||||
|
||||
function testDelete(node, offset, text) {
|
||||
doCommand("cmd_deleteCharForward");
|
||||
var msg = "Delete broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
is(editor.textContent, text, msg);
|
||||
synthesizeKey("VK_DELETE", {});
|
||||
is(sel.anchorNode, node, "Delete broken in \"" + editor.innerHTML + "\"");
|
||||
is(sel.anchorOffset, offset, "Delete broken in \"" + editor.innerHTML + "\"");
|
||||
is(editor.textContent, text, "Delete broken in \"" + editor.innerHTML + "\"");
|
||||
}
|
||||
|
||||
function testBackspace(node, offset, text) {
|
||||
doCommand("cmd_deleteCharBackward");
|
||||
var msg = "Backspace broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
is(editor.textContent, text, msg);
|
||||
}
|
||||
|
||||
function testDeletePrevWord(node, offset, text) {
|
||||
doCommand("cmd_deleteWordBackward");
|
||||
var msg = "Delete previous word broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
is(editor.textContent, text, msg);
|
||||
}
|
||||
|
||||
function testDeleteNextWord(node, offset, text) {
|
||||
doCommand("cmd_deleteWordForward");
|
||||
var msg = "Delete next word broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
is(editor.textContent, text, msg);
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
is(sel.anchorNode, node, "Backspace broken in \"" + editor.innerHTML + "\"");
|
||||
is(sel.anchorOffset, offset, "Backspace broken in \"" + editor.innerHTML + "\"");
|
||||
is(editor.textContent, text, "Backspace broken in \"" + editor.innerHTML + "\"");
|
||||
}
|
||||
|
||||
// Test cell-wise deletion of Delete
|
||||
|
@ -179,7 +160,7 @@ function execTests() {
|
|||
|
||||
editor.innerHTML = "foo<div>bar</div>";
|
||||
sel.collapse(editor.firstChild, 3);
|
||||
testDelete(editor.firstChild.nextSibling.firstChild, 3, "foobar");
|
||||
testDelete(editor.firstChild, 3, "foobar");
|
||||
|
||||
// Tests for Bug 419406
|
||||
|
||||
|
@ -188,39 +169,11 @@ function execTests() {
|
|||
testRight(editor.firstChild, 5);
|
||||
testDelete(editor.firstChild, 5, "helloשלום");
|
||||
|
||||
// Tests for Bug 462188
|
||||
editor.innerHTML = "You should not see this text.";
|
||||
sel.collapse(editor.firstChild, 0);
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0should not see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0not see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0text.");
|
||||
testDeleteNextWord(editor, 0, "");
|
||||
|
||||
editor.innerHTML = "You should not see this text.";
|
||||
sel.collapse(editor.firstChild, 29);
|
||||
testDeletePrevWord(editor.firstChild, 24, "You should not see this ");
|
||||
testDeletePrevWord(editor.firstChild, 19, "You should not see ");
|
||||
testDeletePrevWord(editor.firstChild, 15, "You should not ");
|
||||
testDeletePrevWord(editor.firstChild, 11, "You should ");
|
||||
testDeletePrevWord(editor.firstChild, 4, "You ");
|
||||
testDeletePrevWord(editor, 0, "");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(execTests);
|
||||
]]>
|
||||
|
||||
</script>
|
||||
|
||||
<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462188">Mozilla Bug 462188</a>
|
||||
<p id="display"></p>
|
||||
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<iframe id="edit" width="200" height="100" src="about:blank"/>
|
||||
</body>
|
||||
</window>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче