-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[JavaScript] Move 'isDisplayed' atom to be typescript #17316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AutomatedTester
wants to merge
7
commits into
trunk
Choose a base branch
from
atoms-ts-isdisplayed
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1aee808
[JavaScript] Move 'isDisplayed' atom to be typescript
AutomatedTester 32342c3
Use typescript output
AutomatedTester 4bd8a50
move test to not have closure
AutomatedTester 970bd0a
formatting
AutomatedTester c45daee
Handle comments
AutomatedTester 407f0ac
Merge branch 'trunk' into atoms-ts-isdisplayed
AutomatedTester 6bcf634
[javascript] Generate is-displayed-global.js from TypeScript source v…
AutomatedTester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
230 changes: 230 additions & 0 deletions
230
javascript/atoms/test/html5/shadow_dom_typescript_test.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,230 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <link rel="stylesheet" href="/filez/_main/third_party/js/qunit/qunit.css"> | ||
| <script src="/filez/_main/third_party/js/qunit/qunit.js"></script> | ||
| <script src="/filez/_main/third_party/js/qunit/qunit_test_runner.js"></script> | ||
| <script src="../test_bootstrap.js"></script> | ||
| <script src="../../typescript/is-displayed-global.js"></script> | ||
| <script type="text/javascript"> | ||
| goog.require('bot.dom'); | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <div id="qunit"></div> | ||
| <div id="qunit-fixture"></div> | ||
|
|
||
| <h1>Page for Shadow DOM tests</h1> | ||
|
|
||
| <div id="is-shown">Foo</div> | ||
| <div id="is-shown-in-shadow"></div> | ||
| <div id="is-shown-directly-in-shadow"></div> | ||
| <div id="is-shown-in-slot"><div>Foo</div></div> | ||
|
|
||
| <div id="get-parent"><div></div></div> | ||
| <div id="get-parent-slot"><div></div></div> | ||
|
|
||
| <div id="get-text">Foo</div> | ||
| <div id="get-text-shadow"></div> | ||
| <div id="get-text-slot">Foo</div> | ||
| <div id="get-text-slots"> | ||
| <div slot="a">Foo</div> | ||
| <div slot="b">Bar</div> | ||
| <div slot="c">Baz</div> | ||
| </div> | ||
|
|
||
| <script> | ||
| var isShown = bot.dom.typescript.isShown; | ||
| var elementIsShownInShadow; | ||
| var elementIsShown; | ||
| var elementIsShownDirectlyInShadow; | ||
| var elementIsShownInSlot; | ||
|
|
||
| var elementGetParent; | ||
| var elementGetParentSlot; | ||
|
|
||
| var elementGetText; | ||
| var elementGetTextShadow; | ||
| var elementGetTextSlot; | ||
| var elementGetTextSlots; | ||
|
|
||
| if (bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| elementIsShownInShadow = | ||
| document.querySelector('#is-shown-in-shadow'); | ||
| elementIsShownInShadow.attachShadow({ mode: 'open' }); | ||
| elementIsShownInShadow.shadowRoot.innerHTML = | ||
| '<div><div class="test">Foo</div></div>'; | ||
|
|
||
| elementIsShownDirectlyInShadow = | ||
| document.querySelector('#is-shown-directly-in-shadow'); | ||
| elementIsShownDirectlyInShadow.attachShadow({ mode: 'open' }); | ||
| elementIsShownDirectlyInShadow.shadowRoot.innerHTML = | ||
| '<div>Foo</div>'; | ||
|
|
||
| elementIsShown = document.querySelector('#is-shown'); | ||
|
|
||
| elementIsShownInSlot = | ||
| document.querySelector('#is-shown-in-slot'); | ||
| elementIsShownInSlot.attachShadow({ mode: 'open' }); | ||
| elementIsShownInSlot.shadowRoot.innerHTML = | ||
| '<slot></slot>'; | ||
|
|
||
| elementGetParent = | ||
| document.querySelector('#get-parent'); | ||
|
|
||
| elementGetParentSlot = | ||
| document.querySelector('#get-parent-slot'); | ||
| elementGetParentSlot.attachShadow({ mode: 'open' }); | ||
| elementGetParentSlot.shadowRoot.innerHTML = | ||
| '<div><slot></slot></div>'; | ||
|
|
||
| elementGetText = | ||
| document.querySelector('#get-text'); | ||
|
|
||
| elementGetTextShadow = | ||
| document.querySelector('#get-text-shadow'); | ||
| elementGetTextShadow.attachShadow({ mode: 'open' }); | ||
| elementGetTextShadow.shadowRoot.innerHTML = 'foo'; | ||
|
|
||
| elementGetTextSlot = | ||
| document.querySelector('#get-text-slot'); | ||
| elementGetTextSlot.attachShadow({ mode: 'open' }); | ||
| elementGetTextSlot.shadowRoot.innerHTML = | ||
| '<span>a</span><slot></slot><span>b</span>'; | ||
|
|
||
| elementGetTextSlots = | ||
| document.querySelector('#get-text-slots'); | ||
| elementGetTextSlots.attachShadow({ mode: 'open' }); | ||
| elementGetTextSlots.shadowRoot.innerHTML = | ||
| '<slot name="a">Default</slot><slot name="b">Default</slot>'; | ||
| } | ||
|
|
||
| QUnit.test('isShown', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| assert.ok(isShown(elementIsShown)); | ||
|
|
||
| elementIsShown.style.display = 'none'; | ||
|
|
||
| assert.notOk(isShown(elementIsShown)); | ||
| }); | ||
|
|
||
| QUnit.test('isShownInShadow', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| var el = elementIsShownInShadow | ||
| .shadowRoot | ||
| .querySelector('.test'); | ||
|
|
||
| assert.ok(isShown(el)); | ||
|
|
||
| elementIsShownInShadow.style.display = 'none'; | ||
|
|
||
| assert.notOk(isShown(el)); | ||
| }); | ||
|
|
||
| QUnit.test('isShownDirectlyInShadow', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| var el = elementIsShownDirectlyInShadow | ||
| .shadowRoot | ||
| .querySelector('div'); | ||
|
|
||
| assert.ok(isShown(el)); | ||
|
|
||
| elementIsShownDirectlyInShadow.style.display = 'none'; | ||
|
|
||
| assert.notOk(isShown(el)); | ||
| }); | ||
|
|
||
| QUnit.test('isShownInSlot', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| var el = elementIsShownInSlot.children[0]; | ||
|
|
||
| assert.ok(isShown(el)); | ||
|
|
||
| elementIsShownInSlot.style.display = 'none'; | ||
|
|
||
| assert.notOk(isShown(el)); | ||
|
|
||
| elementIsShownInSlot.style.display = ''; | ||
| // Remove the slot, so our child is no longer slotted | ||
| elementIsShownInSlot.shadowRoot.innerHTML = ''; | ||
|
|
||
| assert.notOk(isShown(el)); | ||
| }); | ||
|
|
||
| QUnit.test('getParentNodeInComposedDom', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| var el = elementGetParent.children[0]; | ||
|
|
||
| assert.strictEqual(bot.dom.getParentNodeInComposedDom(el), elementGetParent); | ||
|
|
||
| el = elementGetParentSlot.children[0]; | ||
|
|
||
| assert.strictEqual( | ||
| bot.dom.getParentNodeInComposedDom(el), | ||
| elementGetParentSlot.shadowRoot.querySelector('div') | ||
| ); | ||
|
|
||
| elementGetParentSlot.shadowRoot.innerHTML = ''; | ||
|
|
||
| assert.strictEqual(bot.dom.getParentNodeInComposedDom(el), null); | ||
| }); | ||
|
|
||
| QUnit.test('getVisibleText', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| assert.strictEqual(bot.dom.getVisibleText(elementGetText), 'Foo'); | ||
| }); | ||
|
|
||
| QUnit.test('getVisibleTextInShadow', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| assert.strictEqual(bot.dom.getVisibleText(elementGetTextShadow), 'foo'); | ||
| }); | ||
|
|
||
| QUnit.test('getVisibleTextInSlot', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| assert.strictEqual(bot.dom.getVisibleText(elementGetTextSlot), 'aFoob'); | ||
| }); | ||
|
|
||
| QUnit.test('getVisibleTextInSlots', function(assert) { | ||
| if (!bot.dom.IS_SHADOW_DOM_ENABLED) { | ||
| assert.ok(true, 'Skipping: shadow DOM not enabled'); | ||
| return; | ||
| } | ||
|
|
||
| assert.strictEqual(bot.dom.getVisibleText(elementGetTextSlots), 'Foo\nBar'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.