Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=674770 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 674770</title> |
michael@0 | 8 | <script type="application/javascript" src="/MochiKit/packed.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=674770">Mozilla Bug 674770</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content"> |
michael@0 | 17 | <a href="file_bug674770-1.html" id="link1">test</a> |
michael@0 | 18 | <div contenteditable> |
michael@0 | 19 | <a href="file_bug674770-1.html" id="link2">test</a> |
michael@0 | 20 | </div> |
michael@0 | 21 | </div> |
michael@0 | 22 | <pre id="test"> |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | |
michael@0 | 25 | if (!navigator.platform.startsWith("Linux")) { |
michael@0 | 26 | SimpleTest.expectAssertions(1); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | /** Test for Bug 674770 **/ |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | SimpleTest.waitForFocus(function() { |
michael@0 | 32 | SpecialPowers.setBoolPref("middlemouse.paste", true); |
michael@0 | 33 | localStorage.removeItem("clicked"); |
michael@0 | 34 | window.linkWasClicked = false; |
michael@0 | 35 | |
michael@0 | 36 | var link = document.querySelector("#link1"); |
michael@0 | 37 | addEventListener("storage", function(e) { |
michael@0 | 38 | is(e.key, "clicked", "Correct event"); |
michael@0 | 39 | is(e.newValue, "true", "Correct value"); |
michael@0 | 40 | window.linkWasClicked = true; |
michael@0 | 41 | }, false); |
michael@0 | 42 | synthesizeMouseAtCenter(link, {button: 1}); |
michael@0 | 43 | |
michael@0 | 44 | hitEventLoop(function() { |
michael@0 | 45 | ok(window.linkWasClicked, "The click operation worked successfully"); |
michael@0 | 46 | window.linkWasClicked = false; |
michael@0 | 47 | |
michael@0 | 48 | link = document.querySelector("#link2"); |
michael@0 | 49 | localStorage.removeItem("clicked"); |
michael@0 | 50 | synthesizeMouseAtCenter(link, {button: 1}); |
michael@0 | 51 | |
michael@0 | 52 | hitEventLoop(function() { |
michael@0 | 53 | ok(!window.linkWasClicked, "The click operation shouldn't work in the contenteditable area"); |
michael@0 | 54 | |
michael@0 | 55 | localStorage.removeItem("clicked"); |
michael@0 | 56 | SpecialPowers.clearUserPref("middlemouse.paste"); |
michael@0 | 57 | SimpleTest.finish(); |
michael@0 | 58 | }, 100); |
michael@0 | 59 | }, 100); |
michael@0 | 60 | }); |
michael@0 | 61 | |
michael@0 | 62 | function hitEventLoop(func, times) { |
michael@0 | 63 | if (times > 0) { |
michael@0 | 64 | setTimeout(hitEventLoop, 0, func, times - 1); |
michael@0 | 65 | } else { |
michael@0 | 66 | setTimeout(func, 0); |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | </script> |
michael@0 | 71 | </pre> |
michael@0 | 72 | </body> |
michael@0 | 73 | </html> |