Bug 820831 - Mochitest changes for contentsScaleFactor on windows; r?jimm draft
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 13 Jul 2015 14:37:40 -0700
changeset 411877 d097be2e8152fc01a5ac092f77652460d584de8f
parent 411876 5f0fba1c14ddaf9cec7c44e4852feb433f37b96f
child 530842 417b616da3be51862242da18de2190c6e6f004ae
push id29011
push userbmo:kyle@nonpolynomial.com
push dateThu, 08 Sep 2016 23:33:29 +0000
reviewersjimm
bugs820831
milestone51.0a1
Bug 820831 - Mochitest changes for contentsScaleFactor on windows; r?jimm MozReview-Commit-ID: A9Q1rU5Z6WR
dom/plugins/test/mochitest/mochitest.ini
dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
dom/plugins/test/mochitest/test_queryContentsScaleFactorWindowed.html
dom/plugins/test/testplugin/nptest.cpp
--- a/dom/plugins/test/mochitest/mochitest.ini
+++ b/dom/plugins/test/mochitest/mochitest.ini
@@ -119,17 +119,19 @@ support-files =
 [test_pluginstream_src.html]
 [test_pluginstream_src_dynamic.html]
 [test_pluginstream_src_referer.html]
 [test_positioning.html]
 skip-if = true # disabled due to oddness, perhaps scrolling of the mochitest window?
 [test_propertyAndMethod.html]
 [test_queryCSSZoomFactor.html]
 [test_queryContentsScaleFactor.html]
-skip-if = toolkit != "cocoa"
+skip-if = (toolkit != "cocoa") || (os != "win")
+[test_queryContentsScaleFactorWindowed.html]
+skip-if = (toolkit != "cocoa") || (os != "win")
 [test_redirect_handling.html]
 [test_secondPlugin.html]
 [test_src_url_change.html]
 [test_streamatclose.html]
 [test_streamNotify.html]
 [test_stringHandling.html]
 [test_twostreams.html]
 [test_visibility.html]
--- a/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
+++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
@@ -16,15 +16,16 @@
       var exceptionThrown = false;
       try {
         contentsScaleFactor = pluginElement.queryContentsScaleFactor();
       } catch (e) {
         exceptionThrown = true;
       }
       is(exceptionThrown, false, "Exception thrown getting contents scale factor.");
       is(isNaN(contentsScaleFactor), false, "Invalid return getting contents scale factor");
+      ok(true, "Got Scale Factor of " + contentsScaleFactor);
       SimpleTest.finish();
     }
   </script>
 
   <embed id="plugin" type="application/x-test" width="400" height="400"></embed>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactorWindowed.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+  <title>NPAPI NPNVcontentsScaleFactor Test</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
+</head>
+
+<body onload="runTests()">
+  <script class="testbody" type="application/javascript">
+    SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
+    function runTests() {
+      var pluginElement = document.getElementById("plugin");
+      var contentsScaleFactor;
+      var exceptionThrown = false;
+      try {
+        contentsScaleFactor = pluginElement.queryContentsScaleFactor();
+      } catch (e) {
+        exceptionThrown = true;
+      }
+      is(exceptionThrown, false, "Exception thrown getting contents scale factor.");
+      is(isNaN(contentsScaleFactor), false, "Invalid return getting contents scale factor");
+      ok(true, "Got Scale Factor of " + contentsScaleFactor);
+      SimpleTest.finish();
+    }
+  </script>
+
+  <embed id="plugin" type="application/x-test" width="400" height="400" wmode="window"></embed>
+</body>
+</html>
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -3916,17 +3916,17 @@ bool getMouseUpEventCount(NPObject* npob
 }
 
 bool queryContentsScaleFactor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   if (argCount != 0)
     return false;
 
   double scaleFactor = 1.0;
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
   NPError err = NPN_GetValue(static_cast<TestNPObject*>(npobj)->npp,
                              NPNVcontentsScaleFactor, &scaleFactor);
   if (err != NPERR_NO_ERROR) {
     return false;
   }
 #endif
   DOUBLE_TO_NPVARIANT(scaleFactor, *result);
   return true;