Skip to content

Loading the syn.js library causes Firefox to change the page position - #30

Closed
andrewnicols wants to merge 1 commit into
bitovi:masterfrom
andrewnicols:keyPosition30
Closed

andrewnicols wants to merge 1 commit into
bitovi:masterfrom
andrewnicols:keyPosition30

Conversation

@andrewnicols

Copy link
Copy Markdown
Contributor

We've noticed that when including the syn.js file, the page position changes. In our case, this has the effect of failing some of our behat tests because it is no longer possible to interact with some Nodes if the page overflow has been disabled.

The library should not have an effect on page position in this way.

This seems to be caused by src/key.js at the point that it focuses on the input field. The comment above this is:

// Firefox 4 won't write key events if the element isn't focused

Considering Firefox doesn't seem to trigger these key events anyway, I feel that this should be removed.

andrewnicols added a commit to andrewnicols/syn that referenced this pull request Feb 20, 2014
@andrewnicols

Copy link
Copy Markdown
Contributor Author

So rather than removing the focus, I opted to restore the original focus, and the document scroll position.
This fixes all of the obscure behat failures we had occurring.

dmonllao pushed a commit to moodlehq/moodle-behat-extension that referenced this pull request Feb 20, 2014
It fixes it's repositioning problem, has to
do with the scroll and focus()
bitovi/syn#30
dmonllao pushed a commit to moodlehq/moodle-behat-extension that referenced this pull request Feb 20, 2014
It fixes it's repositioning problem, has to
do with the scroll and focus()
bitovi/syn#30
dmonllao pushed a commit to moodlehq/moodle-behat-extension that referenced this pull request Feb 20, 2014
It fixes it's repositioning problem, has to
do with the scroll and focus()
bitovi/syn#30
dmonllao pushed a commit to moodlehq/moodle-behat-extension that referenced this pull request Feb 20, 2014
It fixes it's repositioning problem, has to
do with the scroll and focus()
bitovi/syn#30
dmonllao pushed a commit to moodlehq/moodle-behat-extension that referenced this pull request Feb 20, 2014
It fixes it's repositioning problem, has to
do with the scroll and focus()
bitovi/syn#30
@matthewp

Copy link
Copy Markdown
Contributor

Is it possible to add a test for this to see more clearly what is happening? Can't tell from your description.

@andrewnicols

Copy link
Copy Markdown
Contributor Author

I'm not sure how best to write a qunit test for this, but the mere inclusion of dist/syn.js in an HTML file causes the page scroll to jump to the bottom in Firefox.

I've put an example online at http://sandpit.andrewrn.co.uk/syn.html. This example is just a few paragraphs of Lipsum with syn.js included in the document head.

@matthewp

Copy link
Copy Markdown
Contributor

That works, thanks. I'll see if I can put a test together.

@matthewp matthewp added this to the v0.0.3 milestone Feb 20, 2014
@matthewp

Copy link
Copy Markdown
Contributor

This is most likely caused by the feature detection which types into input fields to see what events are triggered. I'm going to rework the feature detection a bit before we accept this fix, it might not be needed.

@andrewnicols

Copy link
Copy Markdown
Contributor Author

Hi Matthew,

Yeah - this does come from the feature detection. Look forward to your fix.

Thanks,

Andrew

matthewp added a commit to matthewp/syn that referenced this pull request Feb 21, 2014
This reworks feature detection just a little bit to move the code into
their own modules so they can be seperately tested.

Fixes bitovi#30 by moving the feature detection to take place at the beginning
of the document instead of the end.

Fixes bitovi#29 by waiting until Syn is finished loading before removing
window.__synthTest. This is interesting bug, it appears (which I cannot
    track down definitively) that the issue is that Firefox isn't firing
the `javascript:__synthTest()` until after the elements have been
removed from the page.
matthewp added a commit to matthewp/syn that referenced this pull request Feb 22, 2014
This reworks feature detection just a little bit to move the code into
their own modules so they can be seperately tested.

Fixes bitovi#30 by moving the feature detection to take place at the beginning
of the document instead of the end.

Fixes bitovi#29 by waiting until Syn is finished loading before removing
window.__synthTest. This is interesting bug, it appears (which I cannot
    track down definitively) that the issue is that Firefox isn't firing
the `javascript:__synthTest()` until after the elements have been
removed from the page.
@matthewp matthewp closed this in d77084b Mar 3, 2014
@dmonllao

dmonllao commented Mar 4, 2014

Copy link
Copy Markdown

Hi @matthewp, I was testing now the last dist/syn.js after d77084b landed and when including Syn library I see a:

Uncaught TypeError: Cannot set property '_oldSynth' of undefined syn.js:1061
checkSupport syn.js:1061

@matthewp

matthewp commented Mar 4, 2014

Copy link
Copy Markdown
Contributor

That's weird, just tested with the latest master and didn't get that error. Which browser/OS are you using?

Reopening this issue as the test is now failing to finish in Firefox 30.

@matthewp matthewp reopened this Mar 4, 2014
matthewp added a commit to matthewp/syn that referenced this pull request Mar 4, 2014
Fixes the test that was failing in Firefox for bitovi#30. The old test was
waiting for the iframe to load and then setting a function on the
iframe's window. But Firefox would call `load` after steal had
completed, so it was unreliable. The fix is to set the function on the
parent window and have the iframe call the `parent.synReady()` function.
This guarantees that the function exists before the iframe script has
finished running. Should close out bitovi#30
@dmonllao

dmonllao commented Mar 5, 2014

Copy link
Copy Markdown

Hi @matthewp,

It is failing in linux + FF 26.0 and linux + chrome 33.

Same error, line 1061:
_Uncaught TypeError: Cannot set property 'oldSynth' of undefined
in chrome and in firefox:
_TypeError: window._synthTest is undefined

matthewp added a commit to matthewp/syn that referenced this pull request Mar 6, 2014
In Firefox JavaScript inside an href (for example:
    `href="javascript:__synthTest()"` fires well after Syn has loaded.
    Instead of trying to predict when it is "safe" to remove this
    function, we're just going to leave it alone as it is double
    underscored and shouldn't conflict with anything. In the future we
    could create a `noConflict` function that removes this. Fixes
    lingering issue in bitovi#30
@matthewp

matthewp commented Mar 6, 2014

Copy link
Copy Markdown
Contributor

Hey @dmonllao If you don't mind, could you pull the ff-scroll branch from my fork and try the dist/syn.js? Shouldn't be a problem there any more.

@dmonllao

dmonllao commented Mar 7, 2014

Copy link
Copy Markdown

Sure, np, now I see:

Uncaught TypeError: Cannot call method 'trigger' of undefined syn.js:1077
checkSupport syn.js:1077

@matthewp

matthewp commented Mar 7, 2014

Copy link
Copy Markdown
Contributor

Hey @dmonllao is this happening in master as well?

@dmonllao

Copy link
Copy Markdown

Hi,

As commented #30 (comment), it was failing before 1077, in 1061

@matthewp

Copy link
Copy Markdown
Contributor

Thanks @dmonllao, sounds like it's unrelated to this change then. Can you post the output of uname -a and put that along with the error message in a new issue? I was unable to recreate in my linux machines but I'll install a VM if necessary to see what's happening. Thanks.

@matthewp matthewp closed this Mar 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants