Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | <html> |
michael@0 | 6 | <!-- |
michael@0 | 7 | https://bugzilla.mozilla.org/show_bug.cgi?id=263683 |
michael@0 | 8 | --> |
michael@0 | 9 | |
michael@0 | 10 | <head> |
michael@0 | 11 | <title>Test for Bug 263683</title> |
michael@0 | 12 | <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 17 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 18 | </head> |
michael@0 | 19 | |
michael@0 | 20 | <body onload="onLoad();" onunload="onUnload();"> |
michael@0 | 21 | <a target="_blank" |
michael@0 | 22 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=263683"> |
michael@0 | 23 | Mozilla Bug 263683 |
michael@0 | 24 | </a> |
michael@0 | 25 | <p id="display"></p> |
michael@0 | 26 | <div id="content" style="display: none"> |
michael@0 | 27 | </div> |
michael@0 | 28 | |
michael@0 | 29 | <pre id="test"> |
michael@0 | 30 | <script type="application/javascript"> |
michael@0 | 31 | |
michael@0 | 32 | /** Test for Bug 263683 **/ |
michael@0 | 33 | |
michael@0 | 34 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 35 | |
michael@0 | 36 | var userSetBG = false; |
michael@0 | 37 | var userValueBG = null; |
michael@0 | 38 | var prefNameBG = "ui.textHighlightBackground"; |
michael@0 | 39 | var userSetFG = false; |
michael@0 | 40 | var userValueFG = null; |
michael@0 | 41 | var prefNameFG = "ui.textHighlightForeground"; |
michael@0 | 42 | |
michael@0 | 43 | function onLoad() { |
michael@0 | 44 | SpecialPowers.pushPrefEnv({'set': [[prefNameBG, "#EF0FFF"], [prefNameFG, "#FFFFFF"]]}, startTest); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function startTest() { |
michael@0 | 48 | var textToSelect = document.getElementById("selecttext"); |
michael@0 | 49 | |
michael@0 | 50 | // Take a snapshot now. This will be used to check that removing the |
michael@0 | 51 | // ranges removes the highlighting correctly |
michael@0 | 52 | var noHighlight = snapshotWindow(window); |
michael@0 | 53 | |
michael@0 | 54 | var controller = SpecialPowers.wrap(window). |
michael@0 | 55 | QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). |
michael@0 | 56 | getInterface(SpecialPowers.Ci.nsIWebNavigation). |
michael@0 | 57 | QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). |
michael@0 | 58 | getInterface(SpecialPowers.Ci.nsISelectionDisplay). |
michael@0 | 59 | QueryInterface(SpecialPowers.Ci.nsISelectionController); |
michael@0 | 60 | |
michael@0 | 61 | // Get selection |
michael@0 | 62 | var findSelection = controller.getSelection(controller.SELECTION_FIND); |
michael@0 | 63 | |
michael@0 | 64 | // Lastly add range |
michael@0 | 65 | var range = document.createRange(); |
michael@0 | 66 | range.selectNodeContents(textToSelect); |
michael@0 | 67 | findSelection.addRange(range); |
michael@0 | 68 | |
michael@0 | 69 | // Take a snapshot of the highlighting |
michael@0 | 70 | var highlighted = snapshotWindow(window); |
michael@0 | 71 | |
michael@0 | 72 | // Clear the highlighting, and take another snapshot |
michael@0 | 73 | findSelection.removeAllRanges(); |
michael@0 | 74 | var removedHighlight = snapshotWindow(window); |
michael@0 | 75 | |
michael@0 | 76 | // Manually "highlight" the text so we can check the rendering |
michael@0 | 77 | textToSelect.style.backgroundColor="#EF0FFF"; |
michael@0 | 78 | textToSelect.style.color="#FFFFFF"; |
michael@0 | 79 | var manualHighlight = snapshotWindow(window); |
michael@0 | 80 | |
michael@0 | 81 | // Test 1: Did the highlighting render correctly? |
michael@0 | 82 | var res = compareSnapshots(highlighted, manualHighlight, true); |
michael@0 | 83 | ok(res[0], "SELECTION_FIND highlighting renders correctly"); |
michael@0 | 84 | |
michael@0 | 85 | // Test 2: Does removing the ranges from the SELECTION_FIND selection |
michael@0 | 86 | // work as expected? |
michael@0 | 87 | res = compareSnapshots(removedHighlight, noHighlight, true); |
michael@0 | 88 | ok(res[0], "Removing ranges from FIND_SELECTION works correctly"); |
michael@0 | 89 | |
michael@0 | 90 | SimpleTest.finish(); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | </script> |
michael@0 | 94 | </pre> |
michael@0 | 95 | |
michael@0 | 96 | <p><span id="selecttext">Text to be selected</span></p> |
michael@0 | 97 | </body> |
michael@0 | 98 | </html> |