diff --git a/browser/components/sessionstore/test/browser/Makefile.in b/browser/components/sessionstore/test/browser/Makefile.in index 41f690d6e5a..3660541c7ef 100644 --- a/browser/components/sessionstore/test/browser/Makefile.in +++ b/browser/components/sessionstore/test/browser/Makefile.in @@ -74,10 +74,23 @@ _BROWSER_TEST_FILES = \ browser_454908_sample.html \ browser_456342.js \ browser_456342_sample.xhtml \ + browser_459906.js \ + browser_459906_empty.html \ + browser_459906_sample.html \ browser_461634.js \ + browser_461743.js \ + browser_461743_sample.html \ + browser_463205.js \ + browser_463205_helper.html \ + browser_463205_sample.html \ browser_463206.js \ browser_463206_sample.html \ browser_464199.js \ + browser_464620_a.html \ + browser_464620_a.js \ + browser_464620_b.html \ + browser_464620_b.js \ + browser_464620_xd.html \ browser_465215.js \ browser_465223.js \ browser_466937.js \ diff --git a/browser/components/sessionstore/test/browser/browser_459906.js b/browser/components/sessionstore/test/browser/browser_459906.js new file mode 100644 index 00000000000..5ea64c3ea6b --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_459906.js @@ -0,0 +1,89 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sessionstore test code. + * + * The Initial Developer of the Original Code is + * Simon Bünzli . + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function test() { + /** Test for Bug 459906 **/ + + waitForExplicitFinish(); + + let testURL = "http://localhost:8888/browser/" + + "browser/components/sessionstore/test/browser/browser_459906_sample.html"; + let uniqueValue = "Unique: " + Date.now(); + + var frameCount = 0; + let tab = gBrowser.addTab(testURL); + tab.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load completely + if (frameCount++ < 2) + return; + this.removeEventListener("load", arguments.callee, true); + + let iframes = tab.linkedBrowser.contentWindow.frames; + iframes[1].document.body.innerHTML = uniqueValue; + + frameCount = 0; + let tab2 = gBrowser.duplicateTab(tab); + tab2.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load (and reload!) completely + if (frameCount++ < 2) + return; + + let maxWait = Date.now() + 1000; + executeSoon(function() { + let iframes = tab2.linkedBrowser.contentWindow.frames; + if (iframes[1].document.body.innerHTML != uniqueValue && Date.now() < maxWait) { + executeSoon(arguments.callee); + return; + } + is(iframes[1].document.body.innerHTML, uniqueValue, + "rich textarea's content correctly duplicated"); + + let innerDomain = null; + try { + innerDomain = iframes[0].document.domain; + } + catch (ex) { /* throws for chrome: documents */ } + is(innerDomain, "localhost", "XSS exploit prevented!"); + + // clean up + gBrowser.removeTab(tab2); + gBrowser.removeTab(tab); + + finish(); + }); + }, true); + }, true); +} diff --git a/browser/components/sessionstore/test/browser/browser_459906_empty.html b/browser/components/sessionstore/test/browser/browser_459906_empty.html new file mode 100644 index 00000000000..e01aaa33948 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_459906_empty.html @@ -0,0 +1,3 @@ +Cross Domain File for bug 459906 + +cheers from localhost diff --git a/browser/components/sessionstore/test/browser/browser_459906_sample.html b/browser/components/sessionstore/test/browser/browser_459906_sample.html new file mode 100644 index 00000000000..d5a16bcf039 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_459906_sample.html @@ -0,0 +1,35 @@ + + + +Test for bug 459906 + + + + + + + diff --git a/browser/components/sessionstore/test/browser/browser_461743.js b/browser/components/sessionstore/test/browser/browser_461743.js new file mode 100644 index 00000000000..0ea9e581f12 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_461743.js @@ -0,0 +1,68 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sessionstore test code. + * + * The Initial Developer of the Original Code is + * Simon Bünzli . + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function test() { + /** Test for Bug 461743 **/ + + waitForExplicitFinish(); + + let testURL = "http://localhost:8888/browser/" + + "browser/components/sessionstore/test/browser/browser_461743_sample.html"; + + let tab = gBrowser.addTab(testURL); + tab.linkedBrowser.addEventListener("load", function(aEvent) { + this.removeEventListener("load", arguments.callee, true); + executeSoon(function() { + let tab2 = gBrowser.duplicateTab(tab); + tab2.linkedBrowser.addEventListener("461743", function(aEvent) { + is(aEvent.data, "done", "XSS injection was attempted"); + + executeSoon(function() { + let iframes = tab2.linkedBrowser.contentWindow.frames; + let innerHTML = iframes[1].document.body.innerHTML; + isnot(innerHTML, Components.utils.reportError.toString(), + "chrome access denied!"); + + // clean up + gBrowser.removeTab(tab2); + gBrowser.removeTab(tab); + + finish(); + }); + }, true, true); + }); + }, true); +} diff --git a/browser/components/sessionstore/test/browser/browser_461743_sample.html b/browser/components/sessionstore/test/browser/browser_461743_sample.html new file mode 100644 index 00000000000..592b4e2f12f --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_461743_sample.html @@ -0,0 +1,43 @@ + + + +Test for bug 461743 + + + + + + + diff --git a/browser/components/sessionstore/test/browser/browser_463205.js b/browser/components/sessionstore/test/browser/browser_463205.js new file mode 100644 index 00000000000..d0a90a59ef6 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_463205.js @@ -0,0 +1,88 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sessionstore test code. + * + * The Initial Developer of the Original Code is + * Simon Bünzli . + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function test() { + /** Test for Bug 463205 **/ + + waitForExplicitFinish(); + + let testURL = "chrome://mochikit/content/browser/" + + "browser/components/sessionstore/test/browser/browser_463205_sample.html"; + + var frameCount = 0; + let tab = gBrowser.addTab(testURL); + tab.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load completely + if (frameCount++ < 3) + return; + this.removeEventListener("load", arguments.callee, true); + + function typeText(aTextField, aValue) { + aTextField.value = aValue; + + let event = aTextField.ownerDocument.createEvent("UIEvents"); + event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0); + aTextField.dispatchEvent(event); + } + + let uniqueValue = "Unique: " + Math.random(); + let win = tab.linkedBrowser.contentWindow; + typeText(win.frames[0].document.getElementById("original"), uniqueValue); + typeText(win.frames[1].document.getElementById("original"), uniqueValue); + + frameCount = 0; + let tab2 = gBrowser.duplicateTab(tab); + tab2.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load (and reload!) completely + if (frameCount++ < 4) + return; + + let win = tab2.linkedBrowser.contentWindow; + isnot(win.frames[0].document.getElementById("original").value, uniqueValue, + "subframes must match URL to get text restored"); + is(win.frames[0].document.getElementById("original").value, "preserve me", + "subframes must match URL to get text restored"); + is(win.frames[1].document.getElementById("original").value, uniqueValue, + "text still gets restored for all other subframes"); + + // clean up + gBrowser.removeTab(tab2); + gBrowser.removeTab(tab); + + finish(); + }, true); + }, true); +} diff --git a/browser/components/sessionstore/test/browser/browser_463205_helper.html b/browser/components/sessionstore/test/browser/browser_463205_helper.html new file mode 100644 index 00000000000..6bfd7d7d8c7 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_463205_helper.html @@ -0,0 +1,4 @@ + +Test for bug 463205 (cross domain) + + diff --git a/browser/components/sessionstore/test/browser/browser_463205_sample.html b/browser/components/sessionstore/test/browser/browser_463205_sample.html new file mode 100644 index 00000000000..c774d0263fc --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_463205_sample.html @@ -0,0 +1,25 @@ + + + +Test for bug 463205 + + + + + + + + diff --git a/browser/components/sessionstore/test/browser/browser_464620_a.html b/browser/components/sessionstore/test/browser/browser_464620_a.html new file mode 100644 index 00000000000..a2cf68cc1d6 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_464620_a.html @@ -0,0 +1,53 @@ + + +Test for bug 464620 (injection on input) + + + + + + +

pending

diff --git a/browser/components/sessionstore/test/browser/browser_464620_a.js b/browser/components/sessionstore/test/browser/browser_464620_a.js new file mode 100644 index 00000000000..671d2122e4d --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_464620_a.js @@ -0,0 +1,79 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sessionstore test code. + * + * The Initial Developer of the Original Code is + * Simon Bünzli . + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function test() { + /** Test for Bug 464620 (injection on input) **/ + + waitForExplicitFinish(); + + let testURL = "http://localhost:8888/browser/" + + "browser/components/sessionstore/test/browser/browser_464620_a.html"; + + var frameCount = 0; + let tab = gBrowser.addTab(testURL); + tab.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load completely + if (frameCount++ < 4) + return; + this.removeEventListener("load", arguments.callee, true); + + executeSoon(function() { + frameCount = 0; + let tab2 = gBrowser.duplicateTab(tab); + tab2.linkedBrowser.addEventListener("464620_a", function(aEvent) { + is(aEvent.data, "done", "XSS injection was attempted"); + + // let form restoration complete and take into account the + // setTimeout(..., 0) in sss_restoreDocument_proxy + executeSoon(function() { + setTimeout(function() { + let win = tab2.linkedBrowser.contentWindow; + isnot(win.frames[0].document.location, testURL, + "cross domain document was loaded"); + ok(!/XXX/.test(win.frames[0].document.body.innerHTML), + "no content was injected"); + + // clean up + gBrowser.removeTab(tab2); + gBrowser.removeTab(tab); + + finish(); + }, 0); + }); + }, true, true); + }); + }, true); +} diff --git a/browser/components/sessionstore/test/browser/browser_464620_b.html b/browser/components/sessionstore/test/browser/browser_464620_b.html new file mode 100644 index 00000000000..164c6a90638 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_464620_b.html @@ -0,0 +1,57 @@ + + +Test for bug 464620 (injection on DOM node insertion) + + + + + + + +

pending

diff --git a/browser/components/sessionstore/test/browser/browser_464620_b.js b/browser/components/sessionstore/test/browser/browser_464620_b.js new file mode 100644 index 00000000000..76bd7851ee0 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_464620_b.js @@ -0,0 +1,79 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sessionstore test code. + * + * The Initial Developer of the Original Code is + * Simon Bünzli . + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function test() { + /** Test for Bug 464620 (injection on DOM node insertion) **/ + + waitForExplicitFinish(); + + let testURL = "http://localhost:8888/browser/" + + "browser/components/sessionstore/test/browser/browser_464620_b.html"; + + var frameCount = 0; + let tab = gBrowser.addTab(testURL); + tab.linkedBrowser.addEventListener("load", function(aEvent) { + // wait for all frames to load completely + if (frameCount++ < 6) + return; + this.removeEventListener("load", arguments.callee, true); + + executeSoon(function() { + frameCount = 0; + let tab2 = gBrowser.duplicateTab(tab); + tab2.linkedBrowser.addEventListener("464620_b", function(aEvent) { + is(aEvent.data, "done", "XSS injection was attempted"); + + // let form restoration complete and take into account the + // setTimeout(..., 0) in sss_restoreDocument_proxy + executeSoon(function() { + setTimeout(function() { + let win = tab2.linkedBrowser.contentWindow; + isnot(win.frames[1].document.location, testURL, + "cross domain document was loaded"); + ok(!/XXX/.test(win.frames[1].document.body.innerHTML), + "no content was injected"); + + // clean up + gBrowser.removeTab(tab2); + gBrowser.removeTab(tab); + + finish(); + }, 0); + }); + }, true, true); + }); + }, true); +} diff --git a/browser/components/sessionstore/test/browser/browser_464620_xd.html b/browser/components/sessionstore/test/browser/browser_464620_xd.html new file mode 100644 index 00000000000..9ec51c4c7b6 --- /dev/null +++ b/browser/components/sessionstore/test/browser/browser_464620_xd.html @@ -0,0 +1,5 @@ +Cross Document File for bug 464620 + + + This document is editable. +