Bug 844113 - Add tests. r=mbrubeck

This commit is contained in:
Jim Mathies 2013-02-22 14:11:45 -06:00
Родитель c2c47ed655
Коммит 32ac9ae336
4 изменённых файлов: 233 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,8 @@ BROWSER_TESTS = \
browser_context_menu_tests.js \
browser_context_menu_tests_01.html \
browser_context_menu_tests_02.html \
browser_context_menu_tests_03.html \
text-block.html \
$(NULL)
BROWSER_TEST_RESOURCES = \

Просмотреть файл

@ -26,7 +26,6 @@ function emptyClipboard() {
.emptyClipboard(Ci.nsIClipboard.kGlobalClipboard);
}
// Image context menu tests
gTests.push({
desc: "text context menu",
run: function test() {
@ -397,6 +396,119 @@ gTests.push({
}
});
gTests.push({
desc: "tests for subframe positioning",
run: function test() {
info(chromeRoot + "browser_context_menu_tests_03.html");
yield addTab(chromeRoot + "browser_context_menu_tests_03.html");
let win = Browser.selectedTab.browser.contentWindow;
// Sometimes the context ui is visible, sometimes it isn't.
try {
yield waitForCondition(function () {
return ContextUI.isVisible;
}, 500, 50);
} catch (ex) {}
ContextUI.dismiss();
let frame1 = win.document.getElementById("frame1");
let link1 = frame1.contentDocument.getElementById("link1");
let promise = waitForEvent(document, "popupshown");
sendContextMenuClickToElement(frame1.contentDocument.defaultView, link1, 85, 10);
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
// should be visible
ok(ContextMenuUI._menuPopup._visible, "is visible");
ok(ContextMenuUI._panel.left > 375 && ContextMenuUI._panel.left < 390, "position");
ok(ContextMenuUI._panel.top > 235 && ContextMenuUI._panel.top < 245, "position");
promise = waitForEvent(document, "popuphidden");
ContextMenuUI.hide();
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
frame1.contentDocument.defaultView.scrollBy(0, 200);
promise = waitForEvent(document, "popupshown");
sendContextMenuClickToElement(frame1.contentDocument.defaultView, link1, 85, 10);
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
// should be visible
ok(ContextMenuUI._menuPopup._visible, "is visible");
ok(ContextMenuUI._panel.left > 375 && ContextMenuUI._panel.left < 390, "position");
ok(ContextMenuUI._panel.top > 35 && ContextMenuUI._panel.top < 45, "position");
promise = waitForEvent(document, "popuphidden");
ContextMenuUI.hide();
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
let rlink1 = win.document.getElementById("rlink1");
promise = waitForEvent(document, "popupshown");
sendContextMenuClickToElement(win, rlink1, 40, 10);
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
// should be visible
ok(ContextMenuUI._menuPopup._visible, "is visible");
ok(ContextMenuUI._panel.left > 730 && ContextMenuUI._panel.left < 745, "position");
ok(ContextMenuUI._panel.top > 600 && ContextMenuUI._panel.top < 610, "position");
promise = waitForEvent(document, "popuphidden");
ContextMenuUI.hide();
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
win.scrollBy(0, 200);
promise = waitForEvent(document, "popupshown");
sendContextMenuClickToElement(win, rlink1, 40, 10);
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
// should be visible
ok(ContextMenuUI._menuPopup._visible, "is visible");
ok(ContextMenuUI._panel.left > 730 && ContextMenuUI._panel.left < 745, "position");
ok(ContextMenuUI._panel.top > 400 && ContextMenuUI._panel.top < 410, "position");
promise = waitForEvent(document, "popuphidden");
ContextMenuUI.hide();
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
let link2 = frame1.contentDocument.getElementById("link2");
promise = waitForEvent(document, "popupshown");
sendContextMenuClickToElement(frame1.contentDocument.defaultView, link2, 85, 10);
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
// should be visible
ok(ContextMenuUI._menuPopup._visible, "is visible");
info(ContextMenuUI._panel.left);
info(ContextMenuUI._panel.top);
ok(ContextMenuUI._panel.left > 380 && ContextMenuUI._panel.left < 390, "position");
ok(ContextMenuUI._panel.top > 170 && ContextMenuUI._panel.top < 185, "position");
promise = waitForEvent(document, "popuphidden");
ContextMenuUI.hide();
yield promise;
ok(promise && !(promise instanceof Error), "promise error");
}
});
function test() {
runTests();
}

Просмотреть файл

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
</head>
<body bgcolor=white>
Hello there. <a href="#hello">hello there.</a>
<center>
<iframe id="frame1" width="800" height="600" src="text-block.html"></iframe>
<br />
<br />
Hello there. <a id="rlink1" href="#hello">hello there.</a>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</center>
</body></html>

Просмотреть файл

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="content">
<p>(start of paragraph)
Alice was beginning to get very (break)<br>
tired of sitting by her sister on the bank, and of having nothing to do: once or twice she (span)
<span>(start of span) had peeped into the book her sister was reading (end of span)</span>,
but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice
`without pictures or conversation?' (break)<br>
(end of paragraph)</p>
(in between paragraphs)
<p>(start of paragraph)
Alice was beginning to get very
tired of sitting by her sister on the bank, and of having nothing to do: once or twice she
had peeped into the book her sister was reading, but it had no pictures or conversations
in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'(break)<br>
(end of paragraph)</p>
<p><a id="link1" href="#hello">(start of paragraph)</a>
So she was considering in her own mind (as well as she could, for the hot day made her
feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth
the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink
eyes ran close by her. <br>
</p>
<p>
There was nothing so VERY remarkable in that; nor did Alice think it so VERY much out of
the way to hear the Rabbit say to itself, `Oh dear! Oh dear! I shall be late!' (when she
thought it over afterwards, it occurred to her that she ought to have wondered at this,
but at the time it all seemed quite natural); but when the Rabbit actually TOOK A WATCH
OUT OF ITS WAISTCOAT- POCKET, and looked at it, and then hurried on, Alice started to her
feet, for it flashed across her mind that she had never before seen a rabbit with either a
waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across
the field after it, and fortunately was just in time to see it pop down a large
rabbit-hole under the hedge. <br>
<br>
In another moment down went Alice after it, never once considering how in the world she
was to get out again. <br>
<br>
The rabbit-hole went straight on like a tunnel for some way, and then dipped suddenly
down, so suddenly that Alice had not a moment to think about stopping herself before she
found herself falling down a very deep well. <br>
<br><a id="link2" href="#hello">(start of paragraph)</a>
Either the well was very deep, or she fell very slowly, for she had plenty of time as she
went down to look about her and to wonder what was going to happen next. First, she tried
to look down and make out what she was coming to, but it was too dark to see anything;
then she looked at the sides of the well, and noticed that they were filled with cupboards
and book-shelves; here and there she saw maps and pictures hung upon pegs. She took down a
jar from one of the shelves as she passed; it was labelled `ORANGE MARMALADE', but to her
great disappointment it was empty: she did not like to drop the jar for fear of killing
somebody, so managed to put it into one of the cupboards as she fell past it. <br>
<br>
`Well!' thought Alice to herself, `after such a fall as this, I shall think nothing of
tumbling down stairs! How brave they'll all think me at home! Why, I wouldn't say anything
about it, even if I fell off the top of the house!' (Which was very likely true.) <br>
<br>
Down, down, down.
<br>
</div>
</body></html>