5 <title>Bug
1398692: Allow toplevel navigation to a data:application/pdf
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
10 <script class=
"testbody" type=
"text/javascript">
12 SimpleTest.waitForExplicitFinish();
14 function test_toplevel_data_pdf() {
15 // The PDF contains one page and it is a
3/
72" square, the minimum allowed by the spec
17 "data:application/pdf;base64,JVBERi0xLjANCjEgMCBvYmo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFI+PmVuZG9iaiAyIDAgb2JqPDwvVHlwZS9QYWdlcy9LaWRzWzMgMCBSXS9Db3VudCAxPj5lbmRvYmogMyAwIG9iajw8L1R5cGUvUGFnZS9NZWRpYUJveFswIDAgMyAzXT4+ZW5kb2JqDQp4cmVmDQowIDQNCjAwMDAwMDAwMDAgNjU1MzUgZg0KMDAwMDAwMDAxMCAwMDAwMCBuDQowMDAwMDAwMDUzIDAwMDAwIG4NCjAwMDAwMDAxMDIgMDAwMDAgbg0KdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4NCnN0YXJ0eHJlZg0KMTQ5DQolRU9G
";
19 let win = window.open(DATA_PDF);
20 let wrappedWin = SpecialPowers.wrap(win);
22 // Unfortunately we can't detect whether the PDF has loaded or not using some
23 // event, hence we are constantly polling location.href till we see that
24 // the data: URI appears. Test times out on failure.
25 var pdfLoaded = setInterval(function() {
26 if (wrappedWin.document.location.href.startsWith("data:application/pdf
")) {
27 clearInterval(pdfLoaded);
28 ok(true, "navigating to data:application/pdf allowed
");
35 SpecialPowers.pushPrefEnv({
36 set: [["security.data_uri.block_toplevel_data_uri_navigations
", true]]
37 }, test_toplevel_data_pdf);