Bug 561733 - Mouse click event in iframe doesn't fire (tests) [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-04-28 09:47:58 -04:00
parent 73abc853b4
commit a3969e33b6
3 changed files with 59 additions and 0 deletions

View File

@ -53,11 +53,13 @@ _BROWSER_FILES = \
browser_bookmarks_tags.js \
browser_select.js \
browser_rect.js \
browser_click_content.js \
browser_FormAssistant.js \
browser_viewport.js \
browser_blank_01.html \
browser_blank_02.html \
browser_select.html \
browser_click_content.html \
browser_FormAssistant.html \
browser_viewport_00.html \
browser_viewport_01.html \

View File

@ -0,0 +1,6 @@
<html>
<title>Browser Click Page 01</title>
<body>
<iframe src="data:,test test" width="100" height="100"><iframe>
</body>
</html>

View File

@ -0,0 +1,51 @@
let testURL_click = "chrome://mochikit/content/browser/mobile/chrome/browser_click_content.html";
let newTab;
let element;
let isClickFired = false;
//------------------------------------------------------------------------------
// Entry point (must be named "test")
function test() {
// This test is async
waitForExplicitFinish();
// Add new tab
newTab = Browser.addTab(testURL_click, true);
ok(newTab, "Tab Opened");
// Wait for tab load (need to check the tab "loading", not the document "loading")
waitFor(testClick, function() { return newTab.isLoading() == false; });
}
function clickFired() {
isClickFired = true;
}
function testClick() {
// Do sanity tests
let uri = newTab.browser.currentURI.spec;
is(uri, testURL_click, "URL Matches newly created Tab");
// Check click
element = newTab.browser.contentDocument.querySelector("iframe");
element.addEventListener("click", clickFired, true);
EventUtils.synthesizeMouseForContent(element, 1, 1, {}, window);
waitFor(checkClick, function() { return isClickFired });
}
function checkClick() {
ok(isClickFired, "Click handler fired");
close();
}
function close() {
// Close the tab
Browser.closeTab(newTab);
// Remove the listener
element.removeEventListener("click", clickFired, true);
// We must finialize the tests
finish();
}