|
1 | 1 | #standardSQL |
2 | 2 | # Section: Content Inclusion - Iframe Sandbox/Permissions Policy |
3 | | -# Question: How often are the allow and sandbox attributes used on iframes? Both per page and over all iframe elements |
| 3 | +# Question: How often are the allow and sandbox attributes used on iframes? Both per page (used in at least one iframe on a page) and over all iframe elements |
| 4 | +WITH total_iframe_count AS ( |
| 5 | + SELECT |
| 6 | + client, |
| 7 | + date, |
| 8 | + SUM(SAFE_CAST(JSON_EXTRACT(custom_metrics, '$.num_iframes') AS INT64)) AS total_iframes |
| 9 | + FROM |
| 10 | + `httparchive.all.pages` |
| 11 | + WHERE |
| 12 | + (date = '2022-06-01' OR date = '2023-06-01' OR date = '2023-12-01' OR date = '2024-03-01' OR date = '2024-04-01' OR date = '2024-05-01' OR date = '2024-06-01') AND |
| 13 | + is_root_page |
| 14 | + GROUP BY client, date |
| 15 | +) |
| 16 | + |
4 | 17 | SELECT |
5 | 18 | client, |
6 | 19 | date, |
7 | | - COUNT(0) AS total_iframes, |
| 20 | + total_iframes, |
8 | 21 | COUNTIF(allow IS NOT NULL) AS freq_allow, |
9 | | - COUNTIF(allow IS NOT NULL) / COUNT(0) AS pct_allow_frames, |
| 22 | + COUNTIF(allow IS NOT NULL) / total_iframes AS pct_allow_frames, |
10 | 23 | COUNTIF(sandbox IS NOT NULL) AS freq_sandbox, |
11 | | - COUNTIF(sandbox IS NOT NULL) / COUNT(0) AS pct_sandbox_frames, |
| 24 | + COUNTIF(sandbox IS NOT NULL) / total_iframes AS pct_sandbox_frames, |
12 | 25 | COUNTIF(allow IS NOT NULL AND sandbox IS NOT NULL) AS freq_both_frames, |
13 | | - COUNTIF(allow IS NOT NULL AND sandbox IS NOT NULL) / COUNT(0) AS pct_both_frames, |
| 26 | + COUNTIF(allow IS NOT NULL AND sandbox IS NOT NULL) / total_iframes AS pct_both_frames, |
14 | 27 | COUNT(DISTINCT url) AS total_urls, |
15 | 28 | COUNT(DISTINCT IF(allow IS NOT NULL, url, NULL)) AS allow_freq_urls, |
16 | 29 | COUNT(DISTINCT IF(allow IS NOT NULL, url, NULL)) / COUNT(DISTINCT url) AS allow_pct_urls, |
|
36 | 49 | is_root_page |
37 | 50 | ) |
38 | 51 | LEFT JOIN UNNEST(iframeAttrs) AS iframeAttr |
39 | | - ) |
| 52 | + ) JOIN total_iframe_count USING (client, date) |
40 | 53 | GROUP BY |
| 54 | + total_iframes, |
41 | 55 | client, |
42 | 56 | date |
43 | 57 | ORDER BY |
|
0 commit comments