Loading toolkit/content/tests/chrome/bug451286_window.xul +48 −16 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ const Ci = Components.interfaces; const Cc = Components.classes; const Cr = Components.results; const SEARCH_TEXT = "text"; const DATAURI = "data:text/html," + SEARCH_TEXT; var gFindBar = null; var gBrowser; Loading @@ -69,7 +71,17 @@ gFindBar = document.getElementById("FindToolbar"); gBrowser = document.getElementById("content"); gBrowser.addEventListener("pageshow", onPageShow, false); gBrowser.loadURI("data:text/html,text<iframe style='display: none;' src='data:text/html,text'></iframe>text<iframe id='if' src='data:text/html,text'></iframe>text"); // Bug 451286. An iframe that should be highlighted var visible = "<iframe id='visible' src='" + DATAURI + "'></iframe>"; // Bug 493658. An invisible iframe that shouldn't interfere with // highlighting matches lying after it in the document var invisible = "<iframe id='invisible' style='display: none;' " + "src='" + DATAURI + "'></iframe>"; var uri = DATAURI + invisible + SEARCH_TEXT + visible + SEARCH_TEXT; gBrowser.loadURI(uri); } let tm = Cc["@mozilla.org/thread-manager;1"]. getService(Ci.nsIThreadManager); Loading @@ -80,9 +92,14 @@ function onPageShow() { gBrowser.removeEventListener("pageshow", onPageShow, false); // First, take a snapshot of the window without highlighting // to be used later to test the unhighlighting case var gWin = gBrowser.contentWindow; var noHighlightSnapshot = snapshotWindow(gWin); gFindBar.open(); var search = "text"; gFindBar._findField.value = search; gFindBar._findField.value = SEARCH_TEXT; var matchCase = gFindBar.getElement("find-case-sensitive"); if (matchCase.checked) matchCase.doCommand(); Loading @@ -91,21 +108,25 @@ gFindBar.toggleHighlight(true); gFindBar.close(); // Take snapshot var gWin = gBrowser.contentWindow; // Take snapshot of highlighing var findSnapshot = snapshotWindow(gWin); // Now, perform the same selections manually // Now, remove the highlighting, and take a snapshot to compare // to our original state gFindBar.open(); gFindBar.toggleHighlight(false); gFindBar.close(); var unhighlightSnapshot = snapshotWindow(gWin); // Select the matches that should have been highlighted manually var doc = gBrowser.contentDocument; var iframe = doc.getElementById("if"); // Create a manual highlight in the visible iframe to test bug 451286 var iframe = doc.getElementById("visible"); var ifBody = iframe.contentDocument.body; var range = iframe.contentDocument.createRange(); range.selectNodeContents(ifBody.childNodes[0]); var ifWindow = doc.getElementById("if").contentWindow; var ifWindow = iframe.contentWindow; var ifDocShell = ifWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell); Loading @@ -114,10 +135,12 @@ .getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController); var findSelection = ifController.getSelection(ifController.SELECTION_FIND); findSelection.addRange(range); var frameFindSelection = ifController.getSelection(ifController.SELECTION_FIND); frameFindSelection.addRange(range); // Create manual highlights in the main document (the matches that lie // before/after the iframes var docShell = gWin.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell); Loading @@ -126,21 +149,30 @@ .getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController); var findSelection2 = controller.getSelection(ifController.SELECTION_FIND); var docFindSelection = controller.getSelection(ifController.SELECTION_FIND); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[0]); findSelection2.addRange(range); docFindSelection.addRange(range); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[2]); findSelection2.addRange(range); docFindSelection.addRange(range); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[4]); findSelection2.addRange(range); docFindSelection.addRange(range); //Take snapshots // Take snapshot of manual highlighting var manualSnapshot = snapshotWindow(gBrowser.contentWindow); // Test 1: Were the matches in iframe correctly highlighted? var res = compareSnapshots(findSnapshot, manualSnapshot, true); ok(res[0], "Matches found in iframe correctly highlighted"); // Test 2: Were the matches in iframe correctly unhighlighted? res = compareSnapshots(noHighlightSnapshot, unhighlightSnapshot, true); ok(res[0], "Highlighting in iframe correctly removed"); finish(); } ]]></script> Loading Loading
toolkit/content/tests/chrome/bug451286_window.xul +48 −16 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ const Ci = Components.interfaces; const Cc = Components.classes; const Cr = Components.results; const SEARCH_TEXT = "text"; const DATAURI = "data:text/html," + SEARCH_TEXT; var gFindBar = null; var gBrowser; Loading @@ -69,7 +71,17 @@ gFindBar = document.getElementById("FindToolbar"); gBrowser = document.getElementById("content"); gBrowser.addEventListener("pageshow", onPageShow, false); gBrowser.loadURI("data:text/html,text<iframe style='display: none;' src='data:text/html,text'></iframe>text<iframe id='if' src='data:text/html,text'></iframe>text"); // Bug 451286. An iframe that should be highlighted var visible = "<iframe id='visible' src='" + DATAURI + "'></iframe>"; // Bug 493658. An invisible iframe that shouldn't interfere with // highlighting matches lying after it in the document var invisible = "<iframe id='invisible' style='display: none;' " + "src='" + DATAURI + "'></iframe>"; var uri = DATAURI + invisible + SEARCH_TEXT + visible + SEARCH_TEXT; gBrowser.loadURI(uri); } let tm = Cc["@mozilla.org/thread-manager;1"]. getService(Ci.nsIThreadManager); Loading @@ -80,9 +92,14 @@ function onPageShow() { gBrowser.removeEventListener("pageshow", onPageShow, false); // First, take a snapshot of the window without highlighting // to be used later to test the unhighlighting case var gWin = gBrowser.contentWindow; var noHighlightSnapshot = snapshotWindow(gWin); gFindBar.open(); var search = "text"; gFindBar._findField.value = search; gFindBar._findField.value = SEARCH_TEXT; var matchCase = gFindBar.getElement("find-case-sensitive"); if (matchCase.checked) matchCase.doCommand(); Loading @@ -91,21 +108,25 @@ gFindBar.toggleHighlight(true); gFindBar.close(); // Take snapshot var gWin = gBrowser.contentWindow; // Take snapshot of highlighing var findSnapshot = snapshotWindow(gWin); // Now, perform the same selections manually // Now, remove the highlighting, and take a snapshot to compare // to our original state gFindBar.open(); gFindBar.toggleHighlight(false); gFindBar.close(); var unhighlightSnapshot = snapshotWindow(gWin); // Select the matches that should have been highlighted manually var doc = gBrowser.contentDocument; var iframe = doc.getElementById("if"); // Create a manual highlight in the visible iframe to test bug 451286 var iframe = doc.getElementById("visible"); var ifBody = iframe.contentDocument.body; var range = iframe.contentDocument.createRange(); range.selectNodeContents(ifBody.childNodes[0]); var ifWindow = doc.getElementById("if").contentWindow; var ifWindow = iframe.contentWindow; var ifDocShell = ifWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell); Loading @@ -114,10 +135,12 @@ .getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController); var findSelection = ifController.getSelection(ifController.SELECTION_FIND); findSelection.addRange(range); var frameFindSelection = ifController.getSelection(ifController.SELECTION_FIND); frameFindSelection.addRange(range); // Create manual highlights in the main document (the matches that lie // before/after the iframes var docShell = gWin.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell); Loading @@ -126,21 +149,30 @@ .getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController); var findSelection2 = controller.getSelection(ifController.SELECTION_FIND); var docFindSelection = controller.getSelection(ifController.SELECTION_FIND); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[0]); findSelection2.addRange(range); docFindSelection.addRange(range); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[2]); findSelection2.addRange(range); docFindSelection.addRange(range); range = doc.createRange(); range.selectNodeContents(doc.body.childNodes[4]); findSelection2.addRange(range); docFindSelection.addRange(range); //Take snapshots // Take snapshot of manual highlighting var manualSnapshot = snapshotWindow(gBrowser.contentWindow); // Test 1: Were the matches in iframe correctly highlighted? var res = compareSnapshots(findSnapshot, manualSnapshot, true); ok(res[0], "Matches found in iframe correctly highlighted"); // Test 2: Were the matches in iframe correctly unhighlighted? res = compareSnapshots(noHighlightSnapshot, unhighlightSnapshot, true); ok(res[0], "Highlighting in iframe correctly removed"); finish(); } ]]></script> Loading