|
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 | + ].each do |script_url| |
| 1414 | + context "with HTML embed code for CodePen using script url `#{script_url}`" do |
| 1415 | + let(:markdown) do |
| 1416 | + <<-MARKDOWN.strip_heredoc |
1427 | 1417 | <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 |
| 1418 | + <script src="#{script_url}"></script> |
| 1419 | + MARKDOWN |
1430 | 1420 | end
|
1431 |
| - end |
1432 |
| - end |
1433 | 1421 |
|
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 |
| 1422 | + if allowed |
| 1423 | + it "does not sanitize embed code" do |
| 1424 | + should eq <<-HTML.strip_heredoc |
| 1425 | + <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> |
| 1426 | + <script src="#{script_url}"></script> |
| 1427 | + HTML |
| 1428 | + end |
| 1429 | + else |
| 1430 | + it "forces async attribute on script" do |
| 1431 | + should eq <<-HTML.strip_heredoc |
| 1432 | + <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> |
| 1433 | + <script src="#{script_url}" async="async"></script> |
| 1434 | + HTML |
| 1435 | + end |
1455 | 1436 | end
|
1456 | 1437 | end
|
1457 | 1438 | end
|
|
0 commit comments