Skip to content

Commit 706093f

Browse files
committed
Test with noscript
1 parent a5de752 commit 706093f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
noscript behaviour
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
echo "--- Parsing ---\n";
9+
10+
$dom = DOM\HTMLDocument::createFromString("<!doctype html><html><body><noscript><p>hi</p></noscript></body></html>", DOM\HTML_NO_DEFAULT_NS);
11+
var_dump($dom->documentElement->textContent);
12+
echo $dom->saveHTML(), "\n";
13+
echo $dom->saveXML();
14+
15+
echo "--- Modifying the text content: tag ---\n";
16+
17+
$xpath = new DOMXPath($dom);
18+
$noscript = $xpath->query("//noscript")[0];
19+
$noscript->textContent = "<p>bye</p>";
20+
echo $dom->saveHTML(), "\n";
21+
echo $dom->saveXML();
22+
23+
echo "--- Modifying the text content: trick ---\n";
24+
25+
$noscript->textContent = "<!-- </noscript> -->";
26+
echo $dom->saveHTML(), "\n";
27+
echo $dom->saveXML();
28+
29+
?>
30+
--EXPECT--
31+
--- Parsing ---
32+
string(2) "hi"
33+
<!DOCTYPE html><html><head></head><body><noscript><p>hi</p></noscript></body></html>
34+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
35+
<!DOCTYPE html>
36+
<html><head/><body><noscript><p>hi</p></noscript></body></html>
37+
--- Modifying the text content: tag ---
38+
<!DOCTYPE html><html><head></head><body><noscript>&lt;p&gt;bye&lt;/p&gt;</noscript></body></html>
39+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40+
<!DOCTYPE html>
41+
<html><head/><body><noscript>&lt;p&gt;bye&lt;/p&gt;</noscript></body></html>
42+
--- Modifying the text content: trick ---
43+
<!DOCTYPE html><html><head></head><body><noscript>&lt;!-- &lt;/noscript&gt; --&gt;</noscript></body></html>
44+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
45+
<!DOCTYPE html>
46+
<html><head/><body><noscript>&lt;!-- &lt;/noscript&gt; --&gt;</noscript></body></html>

0 commit comments

Comments
 (0)