|
1406 | 1406 | end |
1407 | 1407 |
|
1408 | 1408 | shared_examples_for "override embed code attributes" do |allowed:| |
1409 | | - context "with HTML embed code for CodePen using old script url" do |
1410 | | - let(:markdown) do |
1411 | | - <<-MARKDOWN.strip_heredoc |
1412 | | - <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1413 | | - <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script> |
1414 | | - MARKDOWN |
1415 | | - end |
1416 | | - |
1417 | | - if allowed |
1418 | | - it "does not sanitize embed code" do |
1419 | | - should eq <<-HTML.strip_heredoc |
1420 | | - <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1421 | | - <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script> |
1422 | | - HTML |
1423 | | - end |
1424 | | - else |
1425 | | - it "forces async attribute on script" do |
1426 | | - should eq <<-HTML.strip_heredoc |
| 1409 | + [ |
| 1410 | + "https://production-assets.codepen.io/assets/embed/ei.js", |
| 1411 | + "https://static.codepen.io/assets/embed/ei.js", |
| 1412 | + "https://cpwebassets.codepen.io/assets/embed/ei.js", |
| 1413 | + "https://public.codepenassets.com/embed/index.js", |
| 1414 | + ].each do |script_url| |
| 1415 | + context "with HTML embed code for CodePen using script url `#{script_url}`" do |
| 1416 | + let(:markdown) do |
| 1417 | + <<-MARKDOWN.strip_heredoc |
1427 | 1418 | <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1428 | | - <script src="https://production-assets.codepen.io/assets/embed/ei.js" async="async"></script> |
1429 | | - HTML |
| 1419 | + <script src="#{script_url}"></script> |
| 1420 | + MARKDOWN |
1430 | 1421 | end |
1431 | | - end |
1432 | | - end |
1433 | 1422 |
|
1434 | | - context "with HTML embed code for CodePen" do |
1435 | | - let(:markdown) do |
1436 | | - <<-MARKDOWN.strip_heredoc |
1437 | | - <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1438 | | - <script src="https://static.codepen.io/assets/embed/ei.js"></script> |
1439 | | - MARKDOWN |
1440 | | - end |
1441 | | - |
1442 | | - if allowed |
1443 | | - it "does not sanitize embed code" do |
1444 | | - should eq <<-HTML.strip_heredoc |
1445 | | - <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1446 | | - <script src="https://static.codepen.io/assets/embed/ei.js"></script> |
1447 | | - HTML |
1448 | | - end |
1449 | | - else |
1450 | | - it "forces async attribute on script" do |
1451 | | - should eq <<-HTML.strip_heredoc |
1452 | | - <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
1453 | | - <script src="https://static.codepen.io/assets/embed/ei.js" async="async"></script> |
1454 | | - HTML |
| 1423 | + if allowed |
| 1424 | + it "does not sanitize embed code" do |
| 1425 | + should eq <<-HTML.strip_heredoc |
| 1426 | + <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
| 1427 | + <script src="#{script_url}"></script> |
| 1428 | + HTML |
| 1429 | + end |
| 1430 | + else |
| 1431 | + it "forces async attribute on script" do |
| 1432 | + should eq <<-HTML.strip_heredoc |
| 1433 | + <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p> |
| 1434 | + <script src="#{script_url}" async="async"></script> |
| 1435 | + HTML |
| 1436 | + end |
1455 | 1437 | end |
1456 | 1438 | end |
1457 | 1439 | end |
|
0 commit comments