Phuedx has uploaded a new change for review.
https://gerrit.wikimedia.org/r/277969
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/69/277969/1
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..c2b4a11
--- /dev/null
+++ b/tests/browser/features/step_definitions/switch_views.rb
@@ -0,0 +1,15 @@
+Given(/^I toggle the mobile view$/) do
+ on(Page).toggleMobileView
+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).toggleDesktopView
+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..6e48a78
--- /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..8d09d9c
--- /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 toggleMobileView()
+ toggle_view_mobile_element.click
+ end
+
+ def toggleDesktopView()
+ 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: newchange
Gerrit-Change-Id: Ieac8ab149a54f3f5e6c6f510a63477eb0f9cd342
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits