Bug 844113 - Add tests. r=mbrubeck
authorJim Mathies <jmathies@mozilla.com>
Fri, 22 Feb 2013 14:11:45 -0600
changeset 122900 369c128126d5d9ef77b994bd2405233d045d321f
parent 122899 1fe51bcd9a8a48846cd8ca140d7a193b2039fba3
child 122901 944d5d9aff21a08368d89d98d970f5cf49d14289
push id1387
push userphilringnalda@gmail.com
push dateTue, 26 Feb 2013 22:32:56 +0000
treeherderfx-team@ad4cc4e97774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs844113
milestone22.0a1
Bug 844113 - Add tests. r=mbrubeck
browser/metro/base/tests/Makefile.in
browser/metro/base/tests/browser_context_menu_tests.js
browser/metro/base/tests/browser_context_menu_tests_03.html
browser/metro/base/tests/text-block.html
--- a/browser/metro/base/tests/Makefile.in
+++ b/browser/metro/base/tests/Makefile.in
@@ -21,16 +21,18 @@ BROWSER_TESTS = \
   browser_remotetabs.js \
   browser_downloads.js \
   browser_plugin_input.html \
   browser_plugin_input_mouse.js \
   browser_plugin_input_keyboard.js \
   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 = \
   res\image01.png \
   $(NULL)
 
 libs:: $(BROWSER_TESTS)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/metro/
--- a/browser/metro/base/tests/browser_context_menu_tests.js
+++ b/browser/metro/base/tests/browser_context_menu_tests.js
@@ -21,17 +21,16 @@ function debugClipFlavors(aClip)
 }
 
 // XXX won't work with out of process content
 function emptyClipboard() {
   Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard)
                                        .emptyClipboard(Ci.nsIClipboard.kGlobalClipboard);
 }
 
-// Image context menu tests
 gTests.push({
   desc: "text context menu",
   run: function test() {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
     info(chromeRoot + "browser_context_menu_tests_02.html");
     yield addTab(chromeRoot + "browser_context_menu_tests_02.html");
 
@@ -392,11 +391,124 @@ gTests.push({
     let imagetab = Browser.getTabFromChrome(event.originalTarget);
     ok(imagetab != null, "tab created");
     ok(imagetab.browser.currentURI.spec == "chrome://mochitests/content/metro/res/image01.png", "tab location");
 
     Browser.closeTab(imagetab);
   }
 });
 
+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();
 }
new file mode 100644
--- /dev/null
+++ b/browser/metro/base/tests/browser_context_menu_tests_03.html
@@ -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>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/metro/base/tests/text-block.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>
\ No newline at end of file