jenkins-bot has submitted this change and it was merged.

Change subject: Don't parse URL to manipulate query parameters
......................................................................


Don't parse URL to manipulate query parameters

... in MobileContext::doToggling.

Bug: T129600
Change-Id: Ieac8ab149a54f3f5e6c6f510a63477eb0f9cd342
---
M includes/MobileContext.php
A tests/browser/features/step_definitions/switch_views.rb
A tests/browser/features/step_definitions/switch_views_bug_t129600.rb
A tests/browser/features/support/pages/page.rb
A tests/browser/features/switch_views.feature
5 files changed, 53 insertions(+), 3 deletions(-)

Approvals:
  Florianschmidtwelzow: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index d972cd3..6c7c134 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -963,9 +963,7 @@
                        return;
                }
 
-               $url = $this->getRequest()->getFullRequestURL();
-               $parsed = wfParseUrl( $url );
-               $query = isset( $parsed['query'] ) ? wfCgiToArray( 
$parsed['query'] ) : array();
+               $query = $this->getRequest()->getQueryValues();
                unset( $query['mobileaction'] );
                unset( $query['useformat'] );
                unset( $query['title'] );
diff --git a/tests/browser/features/step_definitions/switch_views.rb 
b/tests/browser/features/step_definitions/switch_views.rb
new file mode 100644
index 0000000..5f289dc
--- /dev/null
+++ b/tests/browser/features/step_definitions/switch_views.rb
@@ -0,0 +1,15 @@
+Given(/^I toggle the mobile view$/) do
+  on(Page).toggle_mobile_view
+end
+
+Then(/^I should see the mobile view$/) do
+  expect(on(Page).toggle_view_desktop_element).to be_visible
+end
+
+Given(/^I toggle the desktop view$/) do
+  on(Page).toggle_desktop_view
+end
+
+Then(/^I should see the desktop view$/) do
+  expect(on(Page).toggle_view_mobile_element).to be_visible
+end
diff --git 
a/tests/browser/features/step_definitions/switch_views_bug_t129600.rb 
b/tests/browser/features/step_definitions/switch_views_bug_t129600.rb
new file mode 100644
index 0000000..9fb87a6
--- /dev/null
+++ b/tests/browser/features/step_definitions/switch_views_bug_t129600.rb
@@ -0,0 +1,5 @@
+Given(/^I am on a page that transcludes content from a special page$/) do
+  api.create_page 'T129600', '{{Special:PrefixIndex/User:Admin/}}'
+
+  step 'I am on the "T129600" page'
+end
diff --git a/tests/browser/features/support/pages/page.rb 
b/tests/browser/features/support/pages/page.rb
new file mode 100644
index 0000000..8dc9a6c
--- /dev/null
+++ b/tests/browser/features/support/pages/page.rb
@@ -0,0 +1,14 @@
+class Page
+  include PageObject
+
+  a(:toggle_view_mobile, css: '.stopMobileRedirectToggle')
+  a(:toggle_view_desktop, id: 'mw-mf-display-toggle')
+
+  def toggle_mobile_view
+    toggle_view_mobile_element.click
+  end
+
+  def toggle_desktop_view
+    toggle_view_desktop_element.click
+  end
+end
diff --git a/tests/browser/features/switch_views.feature 
b/tests/browser/features/switch_views.feature
new file mode 100644
index 0000000..724c281
--- /dev/null
+++ b/tests/browser/features/switch_views.feature
@@ -0,0 +1,18 @@
+@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org 
@vagrant
+Feature: Switch between mobile and desktop views
+
+  Scenario: Switching from desktop view to mobile view
+    Given I am on the "Main Page" page
+    And I toggle the mobile view
+    Then I should see the mobile view
+
+  Scenario: Switching from mobile view to desktop view
+    Given I am on the "Main Page" page
+    And I toggle the mobile view
+    And I toggle the desktop view
+    Then I should see the desktop view
+
+  Scenario: Bug: T129600
+    Given I am on a page that transcludes content from a special page
+    And I toggle the mobile view
+    Then I should see the mobile view

-- 
To view, visit https://gerrit.wikimedia.org/r/277969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieac8ab149a54f3f5e6c6f510a63477eb0f9cd342
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to