Commit a7bab9d7 authored by jcivelli@chromium.org's avatar jcivelli@chromium.org

Restricts MHTML loading to top frames.

Also disabling JavaScript for MHTML documents.
Because JavaScipt is now disabled, MHTML layout tests had to be changed
not to use JavaScript anymore.

BUG=330663
TEST=Run MHTML layout tests.
R=abarth@chromium.org, jschuh@chromium.org

Review URL: https://codereview.chromium.org/161383002

git-svn-id: svn://svn.chromium.org/blink/trunk@169499 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3272befc
This is a very simple page
Very basic page.
PASS
From: <Saved by UnMHT>
Subject: =?iso-2022-jp?B?QSBzaW1wbGUgcGFnZQ==?=
Date: Wed, May 11 2011 15:36:36 GMT-0700
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_NextPart_000_0000_87206557.D2C008B0";
type="text/html"
------=_NextPart_000_0000_87206557.D2C008B0
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/simple_page.html
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Diso-8859-1">
<title>A simple page</title>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.onload = function() {
var span=3Ddocument.createElement("span");
if (window.location !=3D 'http://localhost/simple_page.html' &&
document.domain !=3D 'localhost') {
span.innerHTML = "PASS";
} else {
span.innerHTML = "FAIL window.location=" + window.location +
" document.domain=" + document.domain;
}
document.getElementById('locDiv').appendChild(span);
testRunner.notifyDone();
}
</script>
<base href=3D"http://localhost/"></base></head><body>
<h1>This is a very simple page</h1>
Very <b>basic</b> page.
<div id=3D'locDiv'></div>
</body></html>
------=_NextPart_000_0000_87206557.D2C008B0--
<!DOCTYPE html>
<html lang='en'>
<head>
<title>MHTML Content-Transfer-Encoding none test</title>
</head>
<body>
This is a red square:<br>
<img src="resources/red_square.png">
</body>
</html>
...@@ -15,15 +15,10 @@ Content-Type: text/html; ...@@ -15,15 +15,10 @@ Content-Type: text/html;
<html lang='en'> <html lang='en'>
<head> <head>
<title>MHTML Content-Transfer-Encoding none test</title> <title>MHTML Content-Transfer-Encoding none test</title>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head> </head>
<body> <body>
This is a red square:<br> This is a red square:<br>
<img src="resources/red_square.png" onerror="document.getElementById('error').innerHTML+='Failed to load image!'"> <img src="resources/red_square.png">
<div id="error"></div>
</body> </body>
</html> </html>
......
...@@ -3,6 +3,5 @@ ...@@ -3,6 +3,5 @@
</head><body> </head><body>
This is frame 4!<br> This is frame 4!<br>
<img src="frame_4_files/red_square.png" onerror="document.getElementById('error').innerHTML+='Failed to load image!'"> <img src="frame_4_files/red_square.png">
<div id="error">Failed to load image!</div>
</body></html> </body></html>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
...@@ -16,4 +16,3 @@ Content-Location: http://localhost/invalid-bad-boundary.html ...@@ -16,4 +16,3 @@ Content-Location: http://localhost/invalid-bad-boundary.html
This tests that we don't crash if the MHTML is invalid (bad boundary). This tests that we don't crash if the MHTML is invalid (bad boundary).
</body> </body>
------=_NextPart_000_CA35_2BC72789.A73F63D7-- ------=_NextPart_000_CA35_2BC72789.A73F63D7--
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
This page has an IFrame that tries to load some MHTML.
The load should fail.
--------
Frame: '<!--framePath //<!--frame0-->-->'
--------
<html>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
}
</script>
<body>
This page has an IFrame that tries to load some MHTML.<br>
The load should fail.<br>
<iframe src="simple_page_unmht.mht"></iframe>
</body>
</html>
...@@ -3,18 +3,11 @@ ...@@ -3,18 +3,11 @@
<title>A page that contains multiple nested frames</title> <title>A page that contains multiple nested frames</title>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
}
</script>
</head><body> </head><body>
This page contains several frames.<br> This page contains several frames.<br>
<iframe src="multi_frames_files/frame_0.html"></iframe><br> <iframe src="multi_frames_files/frame_0.html"></iframe><br>
<iframe src="multi_frames_files/frame_1.html"></iframe><br> <iframe src="multi_frames_files/frame_1.html"></iframe><br>
<iframe src="multi_frames_files/frame_2.html"></iframe><br> <iframe src="multi_frames_files/frame_2.html"></iframe><br>
And a red square:<br> And a red square:<br>
<img src="frame_4_data/red_square.png" onerror="document.getElementById('error').innerHTML+='Failed to load image!'"> <img src="frame_4_data/red_square.png">
<div id="error"></div>
</body></html> </body></html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A page that contains multiple nested frames</title>
</head><body>
This page contains several frames.<br>
<iframe src="resources/frame_0.html"></iframe><br>
<iframe src="resources/frame_1.html"></iframe><br>
<iframe src="resources/frame_2.html"></iframe><br>
And a red square:<br>
<img src="resources/red_square.png">
</body></html>
This page contains several frames.
And a red square:
--------
Frame: '<!--framePath //<!--frame0-->-->'
--------
The first frame!
--------
Frame: '<!--framePath //<!--frame1-->-->'
--------
The second frame!
--------
Frame: '<!--framePath //<!--frame2-->-->'
--------
The third frame!
This one contains yet another frame. What a twist!
--------
Frame: '<!--framePath //<!--frame2-->/<!--frame0-->-->'
--------
This is frame 4!
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A page that contains multiple nested frames</title>
</head><body>
This page contains several frames.<br>
<iframe src="resources/frame_0.html"></iframe><br>
<iframe src="resources/frame_1.html"></iframe><br>
<iframe src="resources/frame_2.html"></iframe><br>
And a red square:<br>
<img src="resources/red_square.png">
</body></html>
This page contains several frames.
And a red square:
--------
Frame: '<!--framePath //<!--frame0-->-->'
--------
The first frame!
--------
Frame: '<!--framePath //<!--frame1-->-->'
--------
The second frame!
--------
Frame: '<!--framePath //<!--frame2-->-->'
--------
The third frame!
This one contains yet another frame. What a twist!
--------
Frame: '<!--framePath //<!--frame2-->/<!--frame0-->-->'
--------
This is frame 4!
...@@ -35,12 +35,6 @@ Content-Location: http://localhost/top_frame.html ...@@ -35,12 +35,6 @@ Content-Location: http://localhost/top_frame.html
<HTML><HEAD><TITLE>A page that contains multiple nested frames</TITLE> <HTML><HEAD><TITLE>A page that contains multiple nested frames</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" = <META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type> http-equiv=3DContent-Type>
<SCRIPT>=0A=
if (window.testRunner) {=0A=
testRunner.dumpAsText();=0A=
testRunner.dumpChildFramesAsText();=0A=
}=0A=
</SCRIPT>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD> <META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY>This page contains several frames.<BR><IFRAME=20 <BODY>This page contains several frames.<BR><IFRAME=20
...@@ -48,10 +42,8 @@ src=3D"http://localhost/frame_0.html"></IFRAME><BR><IFRAME=20 ...@@ -48,10 +42,8 @@ src=3D"http://localhost/frame_0.html"></IFRAME><BR><IFRAME=20
src=3D"http://localhost/frame_1.html"></IFRAME><BR><IFRAME=20 src=3D"http://localhost/frame_1.html"></IFRAME><BR><IFRAME=20
src=3D"http://localhost/frame_2.html"></IFRAME><BR>And a red = src=3D"http://localhost/frame_2.html"></IFRAME><BR>And a red =
square:<BR><IMG=20 square:<BR><IMG=20
onerror=3D"document.getElementById('error').innerHTML+=3D'Failed to load =
image!'"=20
src=3D"http://localhost/resources/red_square.png">=20 src=3D"http://localhost/resources/red_square.png">=20
<DIV id=3Derror></DIV></BODY></HTML> </BODY></HTML>
------=_NextPart_001_0023_01CC157B.AAC41680 ------=_NextPart_001_0023_01CC157B.AAC41680
Content-Type: text/html; Content-Type: text/html;
...@@ -91,10 +83,8 @@ Content-Location: http://localhost/frame_4.html ...@@ -91,10 +83,8 @@ Content-Location: http://localhost/frame_4.html
http-equiv=3DContent-Type> http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD> <META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY>This is frame 4!<BR><IMG=20 <BODY>This is frame 4!<BR><IMG=20
onerror=3D"document.getElementById('error').innerHTML+=3D'Failed to load = src=3D"http://localhost/resources/red_square.png">=20
image!'"=20 </BODY></HTML>
src=3D"http://localhost/resources/red_square.png">=20
<DIV id=3Derror></DIV></BODY></HTML>
------=_NextPart_000_0020_01CC157B.AAC3EF70 ------=_NextPart_000_0020_01CC157B.AAC3EF70
Content-Type: text/html; Content-Type: text/html;
......
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A page that contains multiple nested frames</title>
</head><body>
This page contains several frames.<br>
<iframe src="resources/frame_0.html"></iframe><br>
<iframe src="resources/frame_1.html"></iframe><br>
<iframe src="resources/frame_2.html"></iframe><br>
And a red square:<br>
<img src="resources/red_square.png">
</body></html>
This page contains several frames.
And a red square:
--------
Frame: '<!--framePath //<!--frame0-->-->'
--------
The first frame!
--------
Frame: '<!--framePath //<!--frame1-->-->'
--------
The second frame!
--------
Frame: '<!--framePath //<!--frame2-->-->'
--------
The third frame!
This one contains yet another frame. What a twist!
--------
Frame: '<!--framePath //<!--frame2-->/<!--frame0-->-->'
--------
This is frame 4!
...@@ -16,21 +16,13 @@ Content-Location: http://localhost/top_frame.html ...@@ -16,21 +16,13 @@ Content-Location: http://localhost/top_frame.html
<title>A page that contains multiple nested frames</title> <title>A page that contains multiple nested frames</title>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
}
</script>
<base href=3D"http://localhost/"></base></head><body> <base href=3D"http://localhost/"></base></head><body>
This page contains several frames.<br> This page contains several frames.<br>
<iframe src=3D"http://localhost/frame_0.html"></iframe><br> <iframe src=3D"http://localhost/frame_0.html"></iframe><br>
<iframe src=3D"http://localhost/frame_1.html"></iframe><br> <iframe src=3D"http://localhost/frame_1.html"></iframe><br>
<iframe src=3D"http://localhost/frame_2.html"></iframe><br> <iframe src=3D"http://localhost/frame_2.html"></iframe><br>
And a red square:<br> And a red square:<br>
<img onerror=3D"document.getElementById(&#x27;error&#x27;).innerHTML+=3D&#x= <img src=3D"resources/red_square.png">
27;Failed to load image!&#x27;" src=3D"resources/red_square.png">
<div id=3D"error"></div>
</body></html> </body></html>
------=_NextPart_000_0000_58874EE0.2096A571 ------=_NextPart_000_0000_58874EE0.2096A571
Content-Type: text/html; charset="ISO-8859-1" Content-Type: text/html; charset="ISO-8859-1"
...@@ -79,9 +71,7 @@ Content-Location: http://localhost/frame_4.html ...@@ -79,9 +71,7 @@ Content-Location: http://localhost/frame_4.html
<base href=3D"http://localhost/"></base></head><body> <base href=3D"http://localhost/"></base></head><body>
This is frame 4!<br> This is frame 4!<br>
<img onerror=3D"document.getElementById(&#x27;error&#x27;).innerHTML+=3D&#x= <img src=3D"resources/red_square.png">
27;Failed to load image!&#x27;" src=3D"resources/red_square.png">
<div id=3D"error"></div>
</body></html> </body></html>
------=_NextPart_000_0000_58874EE0.2096A571 ------=_NextPart_000_0000_58874EE0.2096A571
Content-Type: image/png Content-Type: image/png
......
This tests that we don't crash if the page contains script that tries to add a resource that isn't in the archive.
From: <Saved by WebKit>
Subject: Google
Date: Fri, 20 Jun 2013 14:36:21 -0700
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_CA35_2BC72789.A73F63D7"
------=_NextPart_000_CA35_2BC72789.A73F63D7
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/new-image-not-in-archive.html
<body onload="new Image().src='resources/not-in-mhtml-archive.png'">
<script> if (window.testRunner) { testRunner.dumpAsText() }</script>
This tests that we don't crash if the page contains script that tries
to add a resource that isn't in the archive.</body>
------=_NextPart_000_CA35_2BC72789.A73F63D7--
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<body onload="onLoad()"> <body onload="onLoad()">
This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.<br><br> This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.<br><br>
There should be only one red square below: There should be only 2 red squares below:
<div id="firstDiv"> <div id="firstDiv">
<img src="resources/red_square.png"><br><br> <img src="resources/red_square.png"><br><br>
</div> </div>
...@@ -17,7 +17,7 @@ The red square below should be hidden by way of CSS.<br> ...@@ -17,7 +17,7 @@ The red square below should be hidden by way of CSS.<br>
<img src="resources/red_square.png"><br><br> <img src="resources/red_square.png"><br><br>
</div> </div>
<div id="thirdDiv"> <div id="thirdDiv">
The red square below should be hidden by way of JavaScript.<br> The red square below should be hidden by way of JavaScript (with JS disabled in MHTML, it still should show).<br>
<img src="resources/red_square.png"><br><br> <img src="resources/red_square.png"><br><br>
</div> </div>
......
<html>
<head>
<link href="resources/hide_image.css" rel="stylesheet" type="text/css">
</head>
<body>
This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.<br><br>
There should be only 2 red squares below:
<div id="firstDiv">
<img src="resources/red_square.png"><br><br>
</div>
<div id="thirdDiv">
The red square below should be hidden by way of JavaScript (with JS disabled in MHTML, it still should show).<br>
<img src="resources/red_square.png"><br><br>
</div>
</body>
</html>
This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.
There should be only one red square below:
...@@ -24,18 +24,11 @@ href=3D"http://localhost/resources/hide_image.css"> ...@@ -24,18 +24,11 @@ href=3D"http://localhost/resources/hide_image.css">
<SCRIPT type=3Dtext/javascript=20 <SCRIPT type=3Dtext/javascript=20
src=3D"http://localhost/resources/remove_image_script.js"></SCRIPT> src=3D"http://localhost/resources/remove_image_script.js"></SCRIPT>
<SCRIPT>=0A=
if (window.testRunner) {=0A=
testRunner.dumpAsText();=0A=
testRunner.waitUntilDone();=0A=
}=0A=
</SCRIPT>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD> <META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY onload=3DonLoad()>This page tests that CSS and JavaScript = <BODY onload=3DonLoad()>This page tests that CSS and JavaScript =
resources are=20 resources are=20
retrieved correctly for MHTML files.<BR><BR>There should be only one red = retrieved correctly for MHTML files.<BR><BR>There should be only 2 red =
square=20 squares=20
below:=20 below:=20
<DIV id=3DfirstDiv><IMG=20 <DIV id=3DfirstDiv><IMG=20
src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV> src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV>
...@@ -43,7 +36,7 @@ src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV> ...@@ -43,7 +36,7 @@ src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV>
CSS.<BR><IMG=20 CSS.<BR><IMG=20
src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV> src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV>
<DIV id=3DthirdDiv>The red square below should be hidden by way of=20 <DIV id=3DthirdDiv>The red square below should be hidden by way of=20
JavaScript.<BR><IMG=20 JavaScript (with JS disabled in MHTML, it still should show).<BR><IMG=20
src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV></BODY><= src=3D"http://localhost/resources/red_square.png"><BR><BR></DIV></BODY><=
/HTML> /HTML>
......
<html>
<head>
<link href="resources/hide_image.css" rel="stylesheet" type="text/css">
</head>
<body>
This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.<br><br>
There should be only 2 red squares below:
<div id="firstDiv">
<img src="resources/red_square.png"><br><br>
</div>
<div id="thirdDiv">
The red square below should be hidden by way of JavaScript (with JS disabled in MHTML, it still should show).<br>
<img src="resources/red_square.png"><br><br>
</div>
</body>
</html>
This page tests that CSS and JavaScript resources are retrieved correctly for MHTML files.
There should be only one red square below:
...@@ -20,16 +20,10 @@ ss"></link> ...@@ -20,16 +20,10 @@ ss"></link>
=20 =20
<script src=3D"resources/remove_image_script.js" type=3D"text/javascript"= <script src=3D"resources/remove_image_script.js" type=3D"text/javascript"=
></script> ></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
</script>
<base href=3D"http://localhost/"></base></head><body onload=3D"onLoad()"> <base href=3D"http://localhost/"></base></head><body onload=3D"onLoad()">
This page tests that CSS and JavaScript resources are retrieved correctly= This page tests that CSS and JavaScript resources are retrieved correctly=
for MHTML files.<br><br> for MHTML files.<br><br>
There should be only one red square below: There should be only 2 red squares below:
<div id=3D"firstDiv"> <div id=3D"firstDiv">
<img src=3D"resources/red_square.png"><br><br> <img src=3D"resources/red_square.png"><br><br>
</div> </div>
...@@ -38,7 +32,8 @@ The red square below should be hidden by way of CSS.<br> ...@@ -38,7 +32,8 @@ The red square below should be hidden by way of CSS.<br>
<img src=3D"resources/red_square.png"><br><br> <img src=3D"resources/red_square.png"><br><br>
</div> </div>
<div id=3D"thirdDiv"> <div id=3D"thirdDiv">
The red square below should be hidden by way of JavaScript.<br> The red square below should be hidden by way of JavaScript (with JS disab=
led in MHTML, it still should show).<br>
<img src=3D"resources/red_square.png"><br><br> <img src=3D"resources/red_square.png"><br><br>
</div> </div>
......
<html><head> <html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Page with square</title> <title>Page with square</title>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
}
</script>
</head><body> </head><body>
This is a red square:<br> This is a red square:<br>
<img src="page_with_image_files/red_square.png" onerror="document.getElementById('error').innerHTML+='Failed to load image!'"> <img src="resources/red_square.png">
<div id="error"></div>
</body></html> </body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Page with square</TITLE>
<META content="text/html; charset=3Dwindows-1252" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16421"></HEAD>
<BODY>This is a red square:<BR><IMG src="resources/red_square.png">
</BODY></HTML>
...@@ -19,19 +19,11 @@ Content-Location: http://localhost/page_with_image.html ...@@ -19,19 +19,11 @@ Content-Location: http://localhost/page_with_image.html
<HTML><HEAD><TITLE>Page with square</TITLE> <HTML><HEAD><TITLE>Page with square</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" = <META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type> http-equiv=3DContent-Type>
<SCRIPT>=0A=
if (window.testRunner) {=0A=
testRunner.dumpAsText();=0A=
}=0A=
=0A=
</SCRIPT>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD> <META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY>This is a red square:<BR><IMG=20 <BODY>This is a red square:<BR><IMG=20
onerror=3D"document.getElementById('error').innerHTML+=3D'Failed to load =
image!'"=20
src=3D"http://localhost/resources/red_square.png">=20 src=3D"http://localhost/resources/red_square.png">=20
<DIV id=3Derror></DIV></BODY></HTML> </BODY></HTML>
------=_NextPart_000_001B_01CC157B.96F808A0 ------=_NextPart_000_001B_01CC157B.96F808A0
Content-Type: image/png Content-Type: image/png
......
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Page with square</title>
</head><body>
This is a red square:<br>
<img src="resources/red_square.png">
</body></html>
...@@ -16,17 +16,9 @@ Content-Location: http://localhost/page_with_image.html ...@@ -16,17 +16,9 @@ Content-Location: http://localhost/page_with_image.html
<title>Page with square</title> <title>Page with square</title>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
}
</script>
<base href=3D"http://localhost/"></base></head><body> <base href=3D"http://localhost/"></base></head><body>
This is a red square:<br> This is a red square:<br>
<img onerror=3D"document.getElementById(&#x27;error&#x27;).innerHTML+=3D&#x= <img src=3D"resources/red_square.png">
27;Failed to load image!&#x27;" src=3D"resources/red_square.png">
<div id=3D"error"></div>
</body></html> </body></html>
------=_NextPart_000_0000_02C8A5EE.D896CA6B ------=_NextPart_000_0000_02C8A5EE.D896CA6B
Content-Type: image/png Content-Type: image/png
......
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Diso-8859-1">
<title>A page with JavaScript</title>
<h1>This page has content generated by JavaScript</h1>
Javascript is not run, so that dynamic content should not show.
<div id=3D"myDiv"></div>
</body></html>
...@@ -9,22 +9,21 @@ Content-Type: multipart/related; ...@@ -9,22 +9,21 @@ Content-Type: multipart/related;
------=_NextPart_000_0000_87206557.D2C008B0 ------=_NextPart_000_0000_87206557.D2C008B0
Content-Type: text/html; charset="ISO-8859-1" Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/base.html Content-Location: http://localhost/page_with_javascript.html
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset= <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Diso-8859-1"> =3Diso-8859-1">
<title>A simple page</title>
</head> <title>A page with JavaScript</title>
<body> <h1>This page has content generated by JavaScript</h1>
<div id="out"></div> Javascript is not run, so that dynamic content should not show.
<div id=3D"myDiv"></div>
<script> <script>
if (window.testRunner) document.getElementById('myDiv').innerHTML =3D
testRunner.dumpAsText(); "JavaScript is in the house!";
if (window.internals.baseURL(document) == "http://localhost/base.html")
out.innerHTML = "PASS";
else
out.innerHTML = "FAIL";
</script> </script>
</body></html> </body></html>
------=_NextPart_000_0000_87206557.D2C008B0-- ------=_NextPart_000_0000_87206557.D2C008B0--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Page with square</TITLE>
<BODY>
Image with an absolute URL:<BR>
<IMG src="resources/red_square.png"/>
<br>
Image with a relative URL:<BR>
<IMG src="resources/red_square.png"/>
</BODY></HTML>
From: "Saved by Windows Internet Explorer 9"
Subject: Page with square
Date: Wed, 18 May 2011 16:49:44 -0700
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_001B_01CC157B.96F808A0"
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16776
This is a multi-part message in MIME format.
------=_NextPart_000_001B_01CC157B.96F808A0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/page_with_image.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Page with square</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY>
Image with an absolute URL:<BR><IMG=20
src=3D"http://localhost/resources/red_square.png"/>=20
<br>Image with a relative URL:<BR><IMG=20
src=3D"resources/red_square.png"/>=20
</BODY></HTML>
------=_NextPart_000_001B_01CC157B.96F808A0
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://localhost/resources/red_square.png
iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAACESURBVEhL7ZYxDoAwCEXB2LGTo46ewXj/zXgV
PQKgexP/Ai6l889/6Stp4HtZjYKOiRCpEpfSEIYgJqxNMFTkFUjVXiZhT6qGirwCqdrLJOxJ1VCR
V6A/1XxNc9jqQ6JkpjTU2rwQR+5c4769YCM5zn/BX4PY33Dljb0+JtiTqqEir8ADWEIY6dz7d1cA
AAAASUVORK5CYII=
------=_NextPart_000_001B_01CC157B.96F808A0--
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>MHTML Tests</title>
</head>
<body>
<h1>MHTML Relaxed Content-Type parameters test</h1>
</body>
</html>
...@@ -15,10 +15,6 @@ Content-Transfer-Encoding: 7bit ...@@ -15,10 +15,6 @@ Content-Transfer-Encoding: 7bit
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<title>MHTML Tests</title> <title>MHTML Tests</title>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head> </head>
<body> <body>
<h1>MHTML Relaxed Content-Type parameters test</h1> <h1>MHTML Relaxed Content-Type parameters test</h1>
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<title>MHTML Tests</title> <title>MHTML Tests</title>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head> </head>
<body> <body>
<h1>MHTML Relaxed Content-Type parameters test</h1> <h1>MHTML Relaxed Content-Type parameters test</h1>
......
<html>
<body>
The first frame!
</body>
</html>
<html>
<body>
The second frame!
</body>
</html>
<html>
<body>
The third frame!<br>
This one contains yet another frame. What a twist!</br>
<iframe src="frame_4.html"></iframe>
</body>
</html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head><body>
This is frame 4!<br>
<img src="red_square.png">
</body></html>
/*
The point is to reach a size of n * 4096 bytes (with n > 1)
followed by a blank line to trigger a bug in SharredBuffer.
Let's go:
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789
*/
h1 { visibility: hidden; }
<html><head><meta charset=3D"ISO-8859-1">
<link rel=3D"stylesheet" type=3D"text/css" href=3D"http://localhost/resourc=
es/style.css">
</head>
<body>
This is a test for a bug in SharedBuffer.
</body></html>
...@@ -14,11 +14,6 @@ Content-Location: http://localhost/sharred_buffer_bug.html ...@@ -14,11 +14,6 @@ Content-Location: http://localhost/sharred_buffer_bug.html
<html><head><meta charset=3D"ISO-8859-1"> <html><head><meta charset=3D"ISO-8859-1">
<link rel=3D"stylesheet" type=3D"text/css" href=3D"http://localhost/resourc= <link rel=3D"stylesheet" type=3D"text/css" href=3D"http://localhost/resourc=
es/style.css"> es/style.css">
<script>
if (window.testRunner) {
testRunner.dumpAsText();
}
</script>
</head> </head>
......
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A simple page</title>
</head><body>
<h1>This is a very simple page</h1>
Very <b>basic</b> page.
</body></html>
...@@ -12,10 +12,6 @@ X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16776 ...@@ -12,10 +12,6 @@ X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16776
<HTML><HEAD><TITLE>A simple page</TITLE> <HTML><HEAD><TITLE>A simple page</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" = <META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type> http-equiv=3DContent-Type>
<SCRIPT>=0A=
if (window.testRunner)=0A=
testRunner.dumpAsText();=0A=
</SCRIPT>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD> <META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY> <BODY>
......
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A simple page</title>
</head><body>
<h1>This is a very simple page</h1>
Very <b>basic</b> page.
</body></html>
...@@ -16,10 +16,6 @@ Content-Location: http://localhost/simple_page.html ...@@ -16,10 +16,6 @@ Content-Location: http://localhost/simple_page.html
<title>A simple page</title> <title>A simple page</title>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
<base href=3D"http://localhost/"></base></head><body> <base href=3D"http://localhost/"></base></head><body>
<h1>This is a very simple page</h1> <h1>This is a very simple page</h1>
Very <b>basic</b> page. Very <b>basic</b> page.
......
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>MHTML Tests</title>
</head>
<body>
<h1>MHTML Content-Transfer-Encoding 7-bit test - ;)</h1>
</body>
</html>
...@@ -13,10 +13,6 @@ Content-Transfer-Encoding: 7bit ...@@ -13,10 +13,6 @@ Content-Transfer-Encoding: 7bit
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<title>MHTML Tests</title> <title>MHTML Tests</title>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head> </head>
<body> <body>
<h1>MHTML Content-Transfer-Encoding 7-bit test - ;)</h1> <h1>MHTML Content-Transfer-Encoding 7-bit test - ;)</h1>
......
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>MHTML Tests</title>
</head>
<body>
<h1>MHTML Content-Transfer-Encoding 8-bit test - 😉</h1>
</body>
</html>
...@@ -589,6 +589,10 @@ void DocumentLoader::clearMainResourceHandle() ...@@ -589,6 +589,10 @@ void DocumentLoader::clearMainResourceHandle()
bool DocumentLoader::maybeCreateArchive() bool DocumentLoader::maybeCreateArchive()
{ {
// Only the top-frame can load MHTML.
if (m_frame->tree().parent())
return false;
// Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
if (!isArchiveMIMEType(m_response.mimeType())) if (!isArchiveMIMEType(m_response.mimeType()))
return false; return false;
...@@ -608,6 +612,9 @@ bool DocumentLoader::maybeCreateArchive() ...@@ -608,6 +612,9 @@ bool DocumentLoader::maybeCreateArchive()
// relative URLs are resolved properly. // relative URLs are resolved properly.
ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url()); ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url());
// The Document has now been created.
document()->enforceSandboxFlags(SandboxAll);
commitData(mainResource->data()->data(), mainResource->data()->size()); commitData(mainResource->data()->data(), mainResource->data()->size());
return true; return true;
} }
......
/*
* Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "FrameTestHelpers.h"
#include "URLTestHelpers.h"
#include "WebFrame.h"
#include "WebView.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Location.h"
#include "core/page/Page.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/Platform.h"
#include "public/platform/WebString.h"
#include "public/platform/WebURL.h"
#include "public/platform/WebURLRequest.h"
#include "public/platform/WebURLResponse.h"
#include "public/platform/WebUnitTestSupport.h"
#include "public/web/WebDocument.h"
#include <gtest/gtest.h>
using namespace blink;
using WebCore::Document;
using WebCore::LocalFrame;
using WebCore::Page;
using WebCore::KURL;
using blink::URLTestHelpers::toKURL;
namespace {
class MHTMLTest : public testing::Test {
public:
MHTMLTest()
{
}
protected:
virtual void SetUp()
{
m_helper.initialize();
}
virtual void TearDown()
{
Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
}
void registerMockedURLLoad(const std::string& url, const WebString& fileName)
{
URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::fromUTF8("mhtml/"), WebString::fromUTF8("text/html"));
}
void loadURLInTopFrame(const WebURL& url)
{
WebURLRequest urlRequest;
urlRequest.initialize();
urlRequest.setURL(url);
m_helper.webView()->mainFrame()->loadRequest(urlRequest);
// Make sure any pending request get served.
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
}
Page* page() const { return m_helper.webViewImpl()->page(); }
private:
FrameTestHelpers::WebViewHelper m_helper;
};
// Checks that the domain is set to the actual MHTML file, not the URL it was
// generated from.
TEST_F(MHTMLTest, CheckDomain)
{
const char kFileURL[] = "file:///simple_test.mht";
// Register the mocked frame and load it.
WebURL url = toKURL(kFileURL);
registerMockedURLLoad(kFileURL, WebString::fromUTF8("simple_test.mht"));
loadURLInTopFrame(url);
ASSERT_TRUE(page());
LocalFrame* frame = page()->mainFrame();
ASSERT_TRUE(frame);
Document* document = frame->document();
ASSERT_TRUE(document);
EXPECT_STREQ(kFileURL, frame->domWindow()->location().href().ascii().data());
WebCore::SecurityOrigin* origin = document->securityOrigin();
EXPECT_STRNE("localhost", origin->domain().ascii().data());
}
}
From: "Saved by Windows Internet Explorer 9"
Subject: A simple page
Date: Wed, 18 May 2011 16:50:01 -0700
MIME-Version: 1.0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/simple_page.html
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16776
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>A simple page</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 9.00.8112.16421"></HEAD>
<BODY>
<H1>This is a very simple page</H1>Very <B>basic</B> page. =
</BODY></HTML>
...@@ -281,6 +281,7 @@ ...@@ -281,6 +281,7 @@
'tests/LinkHighlightTest.cpp', 'tests/LinkHighlightTest.cpp',
'tests/ListenerLeakTest.cpp', 'tests/ListenerLeakTest.cpp',
'tests/MemoryInfo.cpp', 'tests/MemoryInfo.cpp',
'tests/MHTMLTest.cpp',
'tests/OpaqueRectTrackingContentLayerDelegateTest.cpp', 'tests/OpaqueRectTrackingContentLayerDelegateTest.cpp',
'tests/OpenTypeVerticalDataTest.cpp', 'tests/OpenTypeVerticalDataTest.cpp',
'tests/PageSerializerTest.cpp', 'tests/PageSerializerTest.cpp',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment