Commit 8ebb5385 authored by Patrick Wang's avatar Patrick Wang
Browse files

Bug 795317: Test case r=jlebar

parent a42576f8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ MOCHITEST_FILES = \
		file_browserElement_AppFramePermission.html \
		browserElement_AppFramePermission.js \
		test_browserElement_inproc_AppFramePermission.html \
		file_wyciwyg.html \
		browserElement_ExposableURI.js \
		test_browserElement_inproc_ExposableURI.html \
		$(NULL)

# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
@@ -201,6 +204,7 @@ MOCHITEST_FILES += \
		test_browserElement_oop_RemoveBrowserElement.html \
		test_browserElement_oop_DOMRequestError.html \
		test_browserElement_oop_AppFramePermission.html \
		test_browserElement_oop_ExposableURI.html \
		$(NULL)
endif #}
endif #}
+57 −0
Original line number Diff line number Diff line
/* Any copyright is dedicated to the public domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Bug 795317: Test that the browser element sanitizes its URIs by removing the
// "unexposable" parts before sending them in the locationchange event.

"use strict";
SimpleTest.waitForExplicitFinish();

var iframe;


function testPassword() {
  function locationchange(e) {
    var uri = e.detail;
    is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html',
       "Username and password shouldn't be exposed in uri.");
    SimpleTest.finish();
  }

  iframe.addEventListener('mozbrowserlocationchange', locationchange);
  iframe.src = "http://iamuser:iampassword@mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html";
}

function testWyciwyg() {
  var locationChangeCount = 0;

  function locationchange(e) {
    // locationChangeCount:
    //  0 - the first load.
    //  1 - after document.write().
    if (locationChangeCount == 0) {
      locationChangeCount ++;
    } else if (locationChangeCount == 1) {
      var uri = e.detail;
      is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_wyciwyg.html', "Scheme in string shouldn't be wyciwyg");
      iframe.removeEventListener('mozbrowserlocationchange', locationchange);
      SimpleTest.executeSoon(testPassword);
    }
  }

  // file_wyciwyg.html calls document.write() to create a wyciwyg channel.
  iframe.src = 'file_wyciwyg.html';
  iframe.addEventListener('mozbrowserlocationchange', locationchange);
}

function runTest() {
  browserElementTestHelpers.setEnabledPref(true);
  browserElementTestHelpers.addPermission();

  iframe = document.createElement('iframe');
  iframe.mozbrowser = true;
  document.body.appendChild(iframe);
  testWyciwyg();
}

addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+14 −0
Original line number Diff line number Diff line
<html>
<head>
<title>test</title>
<script type="text/javascript">
addEventListener('load', function() {
  window.setTimeout(function() {
    document.write("test");
  }, 0);
});
</script>
</head>
<body>
</body>
</html>
+19 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795317
-->
<head>
  <title>Test for Bug 795317</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795317">Mozilla Bug 795317</a>

<script type="application/javascript;version1.7" src="browserElement_ExposableURI.js"></script>

</body>
</html>
+19 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795317
-->
<head>
  <title>Test for Bug 795317</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795317">Mozilla Bug 795317</a>

<script type="application/javascript;version1.7" src="browserElement_ExposableURI.js"></script>

</body>
</html>