Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75404

Refactor check for new window target to detect a "new window" lang string

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_403_STABLE
    • MDL-75404-401_toolbrickfieldlinkinnewwindow
    • MDL-75404-402_toolbrickfieldlinkinnewwindow
    • MDL-75404-master_toolbrickfieldlinkinnewwindow
    • Hide

      Setup

      1. This test requires a publicly available site (e.g. via ngrok)
      2. Site registered in Brickfield with API key and secret. If you don't have a Brickfield account, you can register here.
      3. Activate your site with Brickfield in "Site administration / Plugins / Admin tools / Accessibility / Brickfield registration" by entering the API and Secret keys.
      4. Enable analysis requests in "Site administration / Plugins / Admin tools / Accessibility / Accessibility toolkit settings"
      5. Restore the 'Accessibility 102' course backup accessibility_102.mbz

      Notes

      These tests require you to switch between the 'before', and the 'after' code.
      To access the 'before' code, you can use the following git command:

      git checkout 9b64511c866076eda7ed0670ec25c2d96e1a0e12
      

      To access the 'after' code, you can use the follow

      git checkout master
      

      Test

      1. Ensure that you are using the before code.
      2. Go to the Accessibility 102 course.
      3. Navigate to your Accessibility report for the Accessibility 102 course, from the course administration menu.
      4. Click on the "Submit to Analyse" button to request that the course is analysed by the accessibility toolkit.
      5. Run cron. (You should edit the brickfield cron tasks at Site administration > Server > Tasks > Scheduled tasks to run every minute to speed up this analysis process so that the brickfield task is run the very next time you run cron.)
      6. Confirm that you can see the following error with Activity of "Assignment - Do you know where you're going to (or your links)?", Check of "Links opening into a new window should warn users in advance." and HTML code of "<a href="https://www.rte.ie/" target="_blank">this link open in a new window</a>".
      7. Switch to the after code.
      8. Update the tool_brickfield code with the patch.
      9. Make a small change, such as adding a space somewhere, to the Assignment - "Do you know where you're going to (or your links)?" Description field, so that the analysis is queued to be repeated. (in the Accessibility 102 course).
      10. Run cron again.
      11. Navigate to your Accessibility report for the Accessibility 102 course again.
        1. This time, the relevant error should NOT appear, as the text "new window" has been detected in the text of the link, so no error is reported anymore. (If there is still an error, just run cron again until you get no error.)

      Alternate test

      1. Ensure that you are using the before code.
      2. Copy the admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php and admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php modified unit tests from the patch links into the base Moodle install into the same directories.
      3. Run this unit tests. Verify they fail on the test for appropriate text.
      4. Install the patched version and rerun the same tests.
        1. Verify the tests that failed now pass.
      5. Switch to the after code.
      Show
      Setup This test requires a publicly available site (e.g. via ngrok) Site registered in Brickfield with API key and secret. If you don't have a Brickfield account, you can register here . Activate your site with Brickfield in "Site administration / Plugins / Admin tools / Accessibility / Brickfield registration" by entering the API and Secret keys. Enable analysis requests in "Site administration / Plugins / Admin tools / Accessibility / Accessibility toolkit settings" Restore the 'Accessibility 102' course backup accessibility_102.mbz Notes These tests require you to switch between the 'before', and the 'after' code. To access the 'before' code, you can use the following git command: git checkout 9b64511c866076eda7ed0670ec25c2d96e1a0e12 To access the 'after' code, you can use the follow git checkout master Test Ensure that you are using the before code. Go to the Accessibility 102 course. Navigate to your Accessibility report for the Accessibility 102 course, from the course administration menu. Click on the "Submit to Analyse" button to request that the course is analysed by the accessibility toolkit. Run cron. (You should edit the brickfield cron tasks at Site administration > Server > Tasks > Scheduled tasks to run every minute to speed up this analysis process so that the brickfield task is run the very next time you run cron.) Confirm that you can see the following error with Activity of "Assignment - Do you know where you're going to (or your links)?", Check of "Links opening into a new window should warn users in advance." and HTML code of "<a href="https://www.rte.ie/" target="_blank">this link open in a new window</a>". Switch to the after code. Update the tool_brickfield code with the patch. Make a small change, such as adding a space somewhere, to the Assignment - "Do you know where you're going to (or your links)?" Description field, so that the analysis is queued to be repeated. (in the Accessibility 102 course). Run cron again. Navigate to your Accessibility report for the Accessibility 102 course again. This time, the relevant error should NOT appear, as the text "new window" has been detected in the text of the link, so no error is reported anymore. (If there is still an error, just run cron again until you get no error.) Alternate test Ensure that you are using the before code. Copy the admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php and admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php modified unit tests from the patch links into the base Moodle install into the same directories. Run this unit tests. Verify they fail on the test for appropriate text. Install the patched version and rerun the same tests. Verify the tests that failed now pass. Switch to the after code.

      It's been decided to make a small change to the checks for links which have a blank target, thus opening in a new window, as discussed in the Moodle forums.

      The minor change is to allow (i.e. not report as an error) a blank target link / area if they have included the phrase "new window" in their link text or area alt text.

      This phrase processing is multilingual aware. It will also do a readability check, to prevent spaces being used in the lang string instead, which would otherwise neutralise this check completely. It does this by adding a test to verify the text is readable before checking for valid phrases.

      Testing:

      Before, the HTML "<a href="www.google.com" target="_blank">This is google (opens in new window)</a>" will be flagged as an error for the check "Links opening into a new window should warn users in advance". After patch is applied, this HTML will pass this check.

            wuzi1999 Karen Holland
            wuzi1999 Karen Holland
            Mike Churchward Mike Churchward
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 43 minutes
                4h 43m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.